title: Link Relations in JSON Representations
body: <p>I'm designing a RESTful API based on JSON representations. In order to comply with HATEOAS, I use links between resources extensively. Therefore, I followed <a href="http://www.subbu.org/blog/2008/10/generalized-linking" rel="noreferrer">this suggestion</a> for serializing links in way very similar to ATOM links. </p>
  
  <p>Now I have sometimes problems identifying the correct link relation type. When a resource contains a link to itself, the <code>self</code> relation is obvious. It gets more complex when the resources are collections and aggregations of sub-resources, or contain many links to related resources.</p>
  
  <p>Take a blog post as an example, and think of a resource that returns a snapshot of the blog post – including the author, tags and comments of this blog post.
  Obviously, this resource contains many subresources and should of course also provides separate links to them:</p>
  
  <p><a href="https://gist.github.com/1133601" rel="noreferrer">Sample Resource:</a></p>
  
  <pre><code>{
     "blogpost":{
        "link":{
           "rel":"self",
           "href":"http://blog/post/4711"
        },
        "author":{
           "name":"Bob",
           "link":{
              "rel":"???",
              "href":"http://author/uri"
           }
        },
        "title":"foobar",
        "content":"A long article here…",
        "comments":[
           {
              "comment":"great article",
              "link":{
                 "rel":"???",
                 "href":"http://blog/post/4711/comment/1"
              },
              "author":{
                 "name":"John Doe",
                 "link":{
                    "rel":"???",
                    "href":"http://author/uri"
                 }
              }
           }
        ],
        "tags":[
           {
              "value":"foo",
              "link":{
                 "rel":"???",
                 "href":"http://blog/post/4711/tag/foo"
              }
           }
        ]
     }
  }
  </code></pre>
  
  <p>So what are appropriate relations for the given links? I know that there are relation types such as <code>tag</code>, but not all of my resources match the existing relation types. Or is it okay to use <code>self</code> when referring to the author/tag/comment, because it relates to the context of the enclosing JSON (sub-)object? What is the semantical entity <code>self</code> is referring to?</p>
  
  <p>RFC 5988 states:</p>
  
  <blockquote>
    <p>The context of the link is either a feed IRI or an entry ID, depending on where it appears</p>
  </blockquote>
  
  <p>How can I interpret this in terms of JSON? Is each new object <code>{…}</code> a new context?</p>
  
  <p>Thanks!</p>