Skip to content
oyvindfanebust edited this page Sep 22, 2014 · 7 revisions

hyperfriendly+json is a simple and extensible hypermedia format adding links to JSON object.

This resource has a single property hello and a single self link.

{
  "_links": {
    "self": { "href": "http://api.example.org/hello" }
  },
  "hello": "hyperfriendly+json"
}

If you want, you can add several links to the same rel. Here is a resource that links to multiple authors.

{
  "_links": {
    "author": [
      { "href": "http://api.example.org/oyvind" },
      { "href": "http://api.example.org/nils" }
    ]
  }
}

Links can contain link profiles that add semantics to the link. This link implements the templated link profile.

{
  "_links" : {
    "linkProfiles": [ "http://profiles.hyperfriendly.net/templated-link" ]
    "usersbyname": {
      "href": "/users{?name}"
    }
  }
}

Resources can also implement profiles by adding a rel profile with a link to one or more profiles. The following is an error resource.

{
  "_links" : {
    "profile": "http://profiles.hyperfriendly.net/error"
  },
  "_errors": [
    {
      "_links": {
        "self": { "href": "http://api.example.org/some-error" }
      },
      "title": "Some error",
      "message": "Some error has occurred"
    }
  ]
}

Clone this wiki locally