Skip to content

Proposal to follow Google and Schema.org's JSON Style Guide: Use "camelCase" Naming Convention #1247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

garrettmac
Copy link

@garrettmac garrettmac commented Dec 25, 2017

Updating Naming Rules.


  • JSON MUST SHOULD use camelCase
  • URLs SHOULD use kebab-case.

with a emphasize on the first

JSON MUST SHOULD use camelCase


Here goes.

I think it should be changed or dropped.

I know this is a heavily opinionated topic, but here goes.
The JSON object property naming conventions seem to favor camelCase.

Styleguides that explicitly say to use camelCase.

Google JSON Style Guide (they follow the JSON.org spec):

  • Property names must be camel-cased, ascii strings.

here are a few more:

W3resource(same thing) state:

Property names must be camel-cased, ascii strings.

Crockford state:

  • Most variables and functions should start with a lower case letter.
  • Names should be formed from the 26 upper and lower case letters (A .. Z, a .. z), the 10 digits (0 .. 9)

Schema.org

Properties start with a lower case letter and are also camelCase.

camelCase in the wild:

Using kebab-case

kebab-case notation has collisions (or does not play nicely) with:

  • The JavaScript Language (you cannot do person.first-name)
  • EmberJs Framework
  • Schema.org / JSON-LD
  • GraphQL / GraphQL Queries? (admittedly haven't done much here)

Conclusion

Issues as a result or related to the spec using saying to use kebab-case are as follows:
#323
#571
#191
#127
#1242
#850
#525
#341

I'd expect they will continue until this issue is resolved, especially as GraphQL becomes more popular.

I think it's safe to assume camelCase won this battle, especially with JSON-LD, schema.org and as GraphQL continues to grow.

I think this spec should it be changed or dropped, curious on your take @dgeb @ethanresnick @tkellen

More Resource and Discussion on web

@garrettmac garrettmac changed the title Updating Naming Convention to follow Google JSON Style Guide Updating Naming Convention to follow Google JSON Style Guide (use camelCase) Dec 25, 2017
@garrettmac garrettmac changed the title Updating Naming Convention to follow Google JSON Style Guide (use camelCase) Proposal to follow Google JSON Style Guide: Use "camelCase" Naming Convention Dec 25, 2017
@garrettmac garrettmac changed the title Proposal to follow Google JSON Style Guide: Use "camelCase" Naming Convention Proposal to follow Google and Schema.org's JSON Style Guide: Use "camelCase" Naming Convention Dec 25, 2017
@dgeb
Copy link
Member

dgeb commented Feb 2, 2018

I appreciate the effort that you put into documenting this issue. I've personally been leaning toward changing the default recommendation for JSON members for a while now. We may have placed too much emphasis on correlating case between URLs and JSON members in forming our current recommendations.

However, we can't use language as strong as **MUST**. At this point, camelCase could only be a recommendation (and even if we were pre-1.0, I would still favor keeping this a recommendation instead of a requirement).

I'll discuss this with the other editors and of course the community should chime in.

@dgeb
Copy link
Member

dgeb commented Feb 2, 2018

By the way, I'm strongly opposed to referencing the Google Style Guide in the spec. But I am open to discussing its recommendations as related to JSON:API.

Would you mind reopening this as an issue instead of a PR, and focus the discussion purely on recommending camel-case for JSON members? After all, we already recommend kebab-case for URLs, so that's not even a change you're proposing.

@ethanresnick
Copy link
Member

focus the discussion purely on recommending camel-case for JSON members?

I would be 100% in favor of this as well.

removed Google Style Guide from spec
@garrettmac
Copy link
Author

garrettmac commented Feb 10, 2018

@dgeb #1247 (comment)

By the way, I'm strongly opposed to referencing the Google Style Guide in the spec.

Why is that? Just curious?.

I see what you're saying. I actually did reference the Google Style Guide in the JSON recommends. Good call. Removed it.

@garrettmac
Copy link
Author

Also moved into an issue #1255

@antonkomarev
Copy link

@garrettmac because it's dependency. If Google will decide to change their naming convention, this will means that {json:api} require to follow it too.

@rtablada
Copy link

rtablada commented Apr 5, 2018

I think that this is an area where better delineation of spec vs recommendations and the community around it is essential.

That said right now the documentation is a bit hazy at best that "members" names apply to attributes, relations, urls, and types.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy