3 ms·
In the section "What about attribute names?" I think they get it wrong by saying that camel case would be better than snake case because it would make more sens
by programminggeek 14y ago
In the section "What about attribute names?" I think they get it wrong by saying that camel case would be better than snake case because it would make more sense in Javascript that way.
The issue I take with that is you can't assume your API consumer is using Javascript at all. Thus, making it camel case might look right in Javascript or many other languages, but weird in Ruby.
There are a lot of good ideas here, but I think the author messed up on that assumption. A huge portion of modern API usage is in Objective-C, Java, PHP, Ruby, C#. So, attribute naming could be valid as FooBar, fooBar, or foo_bar.
I think the right point would be to be consistent in attribute naming style. Pick one format and use that.
Designing your API to be consumed by one language is mostly foolish unless you are the only one using the API.
- earth2marsh 14y agoYes, but JSON is JavaScript Object Notation, not (PHP|Ruby|C#|Java|Other) Object Notation. Therefore, since JSON is a serialization of JavaScript, it recommends that you should adopt the JavaScript convention of camelCase.