WhiteHouse / api-standards

3.08k stars 901 forks source link

JSON design patterns #3

Open bryanhirsch opened 11 years ago

bryanhirsch commented 11 years ago

JSON design patterns - JSON is awesome because it's free form, but there are certain design patterns (e.g., having URLs to all the related resources -- see e.g., GitHub's API which does this really well), and returning either an object (single record) or an array of objects (multiple records).

mstade commented 11 years ago

Actually, JSON is pretty bad when it comes to hypermedia affordances. In fact, it has none! But it's easy to parse into an object model in many languages (particularly JavaScript of course) so if that's what you want, have a look at HAL. I've personally never used it in a project, but hear good things!

inadarei commented 11 years ago

JSON is a base format. It does not have to have much, aside from being easily parseable, I guess. A media-type that builds on top of JSON can definitely expose various kinds of required H-Factors, though.

HAL is a good example, another very good example is: Collection+JSON