Any advice on camelCase vs. snake_case for json parameters, to and from a Rails server.
I’m guessing on standardizing on snake_case, because Rails will send back database objects with with attributes in snake case.
Maybe a reasonable default is to give the other side what the other side expects:
The Google JSON guide states:
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.
“thisPropertyIsAnIdentifier”: “identifier value”
I’ve struggled a bit with this - it’s especially bad when you’re building a polyglot application. It feels weird, but then in my JS I find myself doing a lot of
var someAttribute = body.some_attribute to keep the “different” stuff confined to the edges of my code.