Mike Amundsen is wondering how to express hypermedia in JSON. He rightly identifies that there needs to be a new media type, e.g. application/hypermedia+json. Putting together such a new media type is not hard, but in my view, the real issue is defining a JSON format that can express data/media as well as hypermedia. One possibility is to take the "payload" formats defined by Atom and Atom Publishing Protocol, and translate that into JSON using some simple rules. Here is one, based on example from RFC 5023.
{
"entry" : {
"title" : Atom-Powered Robots Run Amok",
"id" : "urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a",
"updated" : "2003-12-13T18:30:02Z",
"author" : {
"name" : "John Doe"
},
"content": "Some text.",
"link" : {
"rel" : "edit",
"href" : "http://example.org/edit/first-post.atom"
}
}
Yeah, I'm not sure we should pile too much on little JSON's back. JSON is merely a simple data structure serialization format.
My fear is that this is notion of links is at the top of a slippery slope that tries to define a big spec. The inclusion of links in JSON should be by convention. If a certain convention is widely used, fine. But that's not JSON, that's one conventional use of JSON.
Right. My goal was to inject some hypermedia in a representation in some media type. I am not proposing that Atom be used as a *the* format for all media types, but it gives some ideas on what kinds of things are needed to be useful as hypermedia in a representation.