In this document Google JSON Style Guide (recommendations for building JSON APIs at Google),
It recommends that:
-
Property names must be camelCased, ASCII strings.
-
The first character must be a letter, an underscore (_), or a dollar sign ($).
Example:
{
"thisPropertyIsAnIdentifier": "identifier value"
}
My team consistently follows this convention when building REST APIs. There are some reasons:
- First, the JSON convention should be independent of the programming languages because we want our APIs to be consistent doesn’t matter whether there are some APIs implemented using a
camelCase
language (e.g. Java), some others usingsnake_case
language (e.g. Python). - Also, most of our clients are webapp so
camelCase
is preferred - If the client prefers
snake_case
, it still can easily convert data betweensnake_case
andcamelCase
(with the help of libraries)
But I agree that if all the applications use the same type of language (e.g. snake_case
), the JSON convention should also follow.