Is there a standard for naming the keys of a JSON?

0

I'm consuming a JSON, and I want to use the keys of this JSON as a select's options, however the nomenclature is in camelCase and no accents, eg

    "destaques": [
      {
        "fornecedoresCompany": [
          {
            "5OouMaisFuncionarios": "value..."
          }
        ]
      },
    ]

Is there a problem if I use it as follows?

    "Destaques": [
      {
        "Fornecedores Company": [
          {
            "5O ou Mais Funcionários": "value..."
          }
        ]
      },
    ]

If it is not correct to use this way, is there any other solution? With javascript? I need to use the keys as an option to be dynamic, it's no use doing only a validation in the code comparing and changing the string.

    
asked by anonymous 12.07.2018 / 20:57

1 answer

1

There are no limitations to the JSON key, it is a string.

Section 7 of the RFC defines what is string, whereas section 4 defines that a member is made up of <string> <separador> <valor> , so it defines that the JSON key is a generic string.

Note that in some cases a JSON object (not to be confused with JSON array) will be deserialized as a map, and this does not change anything by using spaces in the name of the keys. But there are also some frameworks and libraries that try to associate the key name with some object property, so in those cases you #.

13.07.2018 / 06:49