From IndieWeb
Jump to: navigation, search

JSON (abbreviation for JavaScript Object Notation) is a data serialization format often used by HTTP APIs, growing in popularity instead of XML, and also the canonical output of microformats2 parsers.


HTML first gives you automatic JSON

You should always support a human readable HTML page of any data you publish, and mark it up with microformats2. At that point you don't need a separate JSON representation, because microformats2 parsers give you back canonical JSON which you can then serve if you wish, e.g. see Aaron Parecki's example below.


Accepting JSON POST requests

Main article: JSON form encoded

JSON does not have as wide support for POST requests compared to form-encoded requests.

In most web frameworks you have to jump through hoops to read the raw POST data if it's JSON format.

A Google search can confirm that lots of people are confused about how to handle JSON POST requests: how to receive JSON post in php, ruby, python, node

Indieweb Examples

Barnaby Walters

Previously, Barnaby Walters using Taproot on waterpigs.co.uk would return a JSON version of a document by appending ".json" to the URL. However, in 2014-?? Barnaby dropped support for this.

"I ditched content negotiation because it turned out to be a huge maintentance chore of very little actual value. ...the .json view was essentially the same as the parsed microformat view, and I never used it so it kept breaking"[1]

Aaron Parecki

Aaron Parecki uses p3k on aaronparecki.com to return JSON representations of URLs by appending ".json".

"My .json view is *literally* the parsed microformat view. As in, I render the HTML as normal, then pass it through mf2-php before responding. It's like getting content negotiation for free."[2]

Also see: p3k


See Also

Retrieved from "https://indieweb.org/JSON"
Personal tools
Recent & Upcoming