skip to Main Content

I think standard notation for javascript properties is camelCase (most of frameworks in javascript use camelCase), so JSON keys must be camelCase (according to javascript object notation), also I’ve seen WIKIPEDIA and W3SCHOOLS documentation about JSON, all sample wrote in camelCase, but when see API documentation of Twitter, Facebook, Instagram and … all API key wrote in underscore separated notation.

What is standard notation of JSON?

{
    "firstName" : "behrooz"
}

or

{
    "first_name" : "behrooz"
}

5

Answers


  1. JSON defines no convention for the choice of property names. There is no standard for this.

    Login or Signup to reply.
  2. Here is a snippet on Googles intepretation on JSON naming conventions…

    Choose meaningful property names.
    Property names must conform to the following guidelines:

    • Property names should be meaningful names with defined semantics.
    • Property names must be camel-cased, ascii strings. The first
    • character must be a letter, an underscore (_) or a dollar sign ($).
    • Subsequent characters can be a letter, a digit, an underscore, or a
      dollar sign. Reserved JavaScript keywords should be avoided (A list
      of reserved JavaScript keywords can be found below).

    These guidelines mirror the guidelines for naming JavaScript identifiers. This allows JavaScript clients to access properties using dot notation. (for example, result.thisIsAnInstanceVariable). Here’s an example of an object with one property:

    https://google.github.io/styleguide/jsoncstyleguide.xml?showone=Property_Name_Format#Property_Name_Format

    Login or Signup to reply.
  3. Typically you’ll find JSON keys to be camel cased. This is of course entirely up to the developer, and many APIs use underscores. But the mainstream solution is propertyName.

    Login or Signup to reply.
  4. Well according to JSON API.org

    It should be,

     {
       "first-name": "John"
     }
    
    Login or Signup to reply.
  5. Check JSON standarts specification here:

    https://www.rfc-editor.org/rfc/rfc4627

    As you can see there is not standart format vor objects key.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search