Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion How should HATEOAS Links in a json response be handled and why?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Mike Kelly  
View profile  
 More options Oct 22 2012, 7:02 pm
From: Mike Kelly <mikekelly...@gmail.com>
Date: Tue, 23 Oct 2012 00:02:27 +0100
Local: Mon, Oct 22 2012 7:02 pm
Subject: Re: [api-craft] How should HATEOAS Links in a json response be handled and why?

On Mon, Oct 22, 2012 at 11:40 PM, Steve Klabnik <st...@steveklabnik.com> wrote:
>> Why use an array as a container? According to a java-script dev i know,
>> access to the links would be easier with the links as properties of an
>> object.

> This sucks for multiple relations on one link.

Well, not exactly. For a start, single link relations per link is
in-line with the Web Linking RFC:

http://tools.ietf.org/html/rfc5988#section-3

   In this specification, a link is a typed connection between two
   resources that are identified by Internationalised Resource
   Identifiers (IRIs) [RFC3987], and is comprised of:

   *  A context IRI,
   *  a link relation type (Section 4),
   *  a target IRI, and
   *  optionally, target attributes."

The Link header happens to use multiple space separated rels for
brevity but that actually represents multiple links that share the
same target IRI, each with a single rel.

From a design point of view, prematurely optimising away the common
case (single rel) in favour of multiple rel doesn't make a great deal
of sense when the former is supported naturally by JSON. I think most
API consumers would appreciate keeping this basic necessity (selecting
a link) as simple as possible.

At the end of the day, if you want "multiple rels" that are similar to
the Link header you can achieve the same effect simply by having
multiple links that all point at the same target, e.g. below I have
represented /bob's conflicting emotions toward /ted :

{
  _links: {
    self: { href: "/bob" },
    hate: { href: "/ted" },
    love: { href: "/ted" }
  },
  name: "bob",
  description: "a confused little man",
  age: 50

}


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.