5 ms·
Ask HN: In 2018, should we use SnakeCase or CamelCase for JSON?
Last year, my friend got fired because he used SnakeCase instead of CamelCase for the startup's API.
This year, yet another friend fired for doing the opposite.
- NVRM 9y agoUse unicodes instead! https://codepen.io/Nico_KraZhtest/pen/mEjBdj https://codepen.io/Nico_KraZhtest/pen/mEjBdj
- mtmail 9y agoClearly use whatever your boss tells you to use (otherwise you get fired).
- randomerr 9y ago'camelCase' is the JavaScript standard. Since JSON is an extension of JavaScript I would stick with that. Ex. allTrue, charAt(), indexOf, ect. Mozzila's JSON examples are in 'camelCase': https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/JSON https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Ob... Microsofts's JSON examples are in 'camelCase': https://msdn.microsoft.com/en-us/library/hh923971(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/hh923971(v=vs.85).a...
- bballer 9y agoMy personal preference is to always use snake case, and not just for JSON but for all javascript variables, while keeping all functions names as camel case. Since javascript doesn't have type safety I find that it makes it super easy when looking at code to quickly make a distinction of "is this a function or is this a variable".