Re:Designing Pragmatic RESTful APIs
by earth2marsh on Wednesday December 05, 2012 @01:50AM
(#4875265)
Yes, 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.
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.