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
Embedded resources in hal+json
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  12 messages - Collapse all  -  Translate all to Translated (View all originals)
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 Jan 25 2012, 10:37 am
From: Mike Kelly <mikekelly...@gmail.com>
Date: Wed, 25 Jan 2012 15:37:47 +0000
Local: Wed, Jan 25 2012 10:37 am
Subject: Embedded resources in hal+json

The _embedded property seems to get questioned a lot.. people ask why it is
needed and why HAL doesn't have a model whereby resources are embedded
directly, i.e.:

{
.....
  "father": {
    "_links": { "self" : { "href": "...." } },
    "first_name": "Bob",
    ...
  },
.....

}

this.father.first_name #=> "Bob"

vs. how we have it now:

{
.....
  "_embedded":
    "father": {
      "_links": { "self" : { "href": "...." } },
      "first_name": "Bob",
      ...
    }
  }
.....

}

this._embedded.father.first_name #=> Bob

I designed it this way so that resources would be embedded explicitly in
the containing object which would be more efficient to parse, since the
alternative requires a parser to run through the entire object hierarchies
to look for a _links property and established what the embedded resources
are.

I guess the benefit of not using _embedded is that it is 'simpler' and less
convoluted.. I just can't make up my mind which is the better option - I
was wondering if anyone had any strong preferences or further insights on
the pros and cons?

Cheers,
Mike


 
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.
Steve Michelotti  
View profile  
 More options Jan 25 2012, 10:59 am
From: Steve Michelotti <steve.michelo...@gmail.com>
Date: Wed, 25 Jan 2012 07:59:01 -0800 (PST)
Local: Wed, Jan 25 2012 10:59 am
Subject: Re: Embedded resources in hal+json
I haven't had to write a JSON parser for this yet so maybe I'll regret
saying this but...I like the first option better. The reason is
because it makes things more elegant for the consumer not to have to
refer to this odd "_embedded" property when working with the code. My
vote is to err on making the life easier for human consumers rather
than parsers.

On Jan 25, 10:37 am, Mike Kelly <mikekelly...@gmail.com> wrote:


 
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.
Mike Kelly  
View profile  
 More options Jan 25 2012, 11:25 am
From: Mike Kelly <mikekelly...@gmail.com>
Date: Wed, 25 Jan 2012 16:25:13 +0000
Local: Wed, Jan 25 2012 11:25 am
Subject: Re: Embedded resources in hal+json

Developers writing parsers aren't human consumers? :)

Think I get your point, though. cheers

On Wed, Jan 25, 2012 at 3:59 PM, Steve Michelotti <


 
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.
Bob Ferris  
View profile  
 More options Jan 25 2012, 11:50 am
From: Bob Ferris <z...@smiy.org>
Date: Wed, 25 Jan 2012 17:50:39 +0100
Local: Wed, Jan 25 2012 11:50 am
Subject: Re: Embedded resources in hal+json
Hi Mike,

I thought, that it is especially important for a hypermedia driven
application client to know which resource is (partly or completely)
transcluded into the requested resource (root resource). It states,
amongst others, that this information about that resource is enough at
the moment to step into another application state (, i.e. make a choice
for a next step). So, one does not have to dereference the URI of that
resource before (as it would maybe the case in RDF).
Otherwise, I would tend to say that HAL is then closer aligned to
knowledge representation languages la RDF ;)

Cheers,

Bo

On 1/25/2012 4:37 PM, Mike Kelly wrote:


 
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.
kaiplusuwe  
View profile  
 More options Jan 25 2012, 11:53 am
From: kaiplusuwe <kaiplus...@googlemail.com>
Date: Wed, 25 Jan 2012 08:53:28 -0800 (PST)
Local: Wed, Jan 25 2012 11:53 am
Subject: Re: Embedded resources in hal+json
I actually like the idea of making a difference between association
and aggregation:

association = a simple link, loose coupling:

"order":
{
    "_links": {
      "self": { "href": "/orders/123" },
      "customer": { "href": "/customer/bob", "title": "Bob Jones
<b...@jones.com>" }
    },
    "total": 30.00,
    "status": "shipped",
    "placed": "2011-01-16"

}

aggregation = embedded sub resource (required if attributes are
included, e.g. for performance purposes):

"order":
{
    "_links": {
      "self": { "href": "/orders/123" },
    },
    "_embedded": {
        "customer": {
            "_links": {
                "self": { "href": "/customer/bob", "title": "Bob Jones
<b...@jones.com>" },
            },
            "name": "Bob Jones"
        }
    }
    "total": 30.00,
    "status": "shipped",
    "placed": "2011-01-16",

}

But what I'm wondering about is the way *list resources* are
presented. Could we also ave the simple "association" way or is this
not consistent with the HAL ideas?:

{
  "_links": {
    "self": { "href": "/orders" },
    "next": { "href": "/orders?page=2" },
    "search": { "href": "/orders?id={order_id}" }
    "order": [
      { "href": "/orders/123", "title": "order 123 from Wed, Jan 25,
2012 at 4:00 PM" },
      { "href": "/orders/124", "title": "order 124 from Wed, Jan 25,
2012 at 4:01 PM" },
      { "href": "/orders/125", "title": "order 125 from Wed, Jan 25,
2012 at 4:02 PM" },
      { "href": "/orders/126", "title": "order 126 from Wed, Jan 25,
2012 at 4:03 PM" },
      { "href": "/orders/127", "title": "order 127 from Wed, Jan 25,
2012 at 4:04 PM" },
      { "href": "/orders/128", "title": "order 128 from Wed, Jan 25,
2012 at 4:05 PM" },
      { "href": "/orders/129", "title": "order 129 from Wed, Jan 25,
2012 at 4:06 PM" }
    ]
  }

}

Have fun, enjoy,
Kai-Uwe

On 25 Jan., 16:37, Mike Kelly <mikekelly...@gmail.com> wrote:


 
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.
Mike Kelly  
View profile  
 More options Jan 25 2012, 12:02 pm
From: Mike Kelly <mikekelly...@gmail.com>
Date: Wed, 25 Jan 2012 17:02:13 +0000
Local: Wed, Jan 25 2012 12:02 pm
Subject: Re: Embedded resources in hal+json

Hi Bob,

This is still the same transclusion mechanism, the difference is really
only in the way in which the translusion is modeled in JSON.

It only affects how clients are required to establish what resources are
transcluded for a given resource; since removing _embedded would
potentially require clients to iterate over all properties of a resource
object and determine whether or not they are transclusions. This would be
an expensive process for large resources with many properties.. having said
that iterating over to establish all the available transclusions is only
really necessary in a 'discovery' situation, and not really needed if the
client already knows which transclusions it is looking for.

Cheers,
Mike


 
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.
Mike Kelly  
View profile  
 More options Jan 25 2012, 12:06 pm
From: Mike Kelly <mikekelly...@gmail.com>
Date: Wed, 25 Jan 2012 17:06:24 +0000
Local: Wed, Jan 25 2012 12:06 pm
Subject: Re: Embedded resources in hal+json

The beginning of the second paragraph isn't very clear, should've been this:

"It only affects how clients are required to establish what transclusions
exist for a given resource; since removing _embedded would require clients
to iterate over all properties of a resource object in order to determine
which of them are transclusions (i.e. selecting properties that are objects
and have their own _links property)"


 
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.
Mike Kelly  
View profile  
 More options Jan 25 2012, 12:11 pm
From: Mike Kelly <mikekelly...@gmail.com>
Date: Wed, 25 Jan 2012 17:11:59 +0000
Local: Wed, Jan 25 2012 12:11 pm
Subject: Re: Embedded resources in hal+json

On Wed, Jan 25, 2012 at 4:47 PM, kaiplusuwe <kaiplus...@googlemail.com>wrote:

Hello - yes that is a valid use of a _links property in hal+json, it's
written into the spec:

"Relations with one corresponding Resource/Link have a single object value,
relations with multiple corresponding HAL elements have an array of objects
as their value."

Is that what you meant? Maybe this needs to be clearer?

Cheers,
Mike


 
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.
Mark Derricutt  
View profile  
 More options Jan 25 2012, 2:47 pm
From: Mark Derricutt <m...@talios.com>
Date: Thu, 26 Jan 2012 08:47:01 +1300
Local: Wed, Jan 25 2012 2:47 pm
Subject: Re: Embedded resources in hal+json

+1 on the current design.  It's preferable for me that there's a separation
between a resource and another.  Also, given that embedded resources have
rels which identify how they relate, having the container object makes a
lot of sense.  I don't see how you'd do that otherwise, unless you embed
inside the resource the _rel which implies following a resource THEN
finding out WHY you followed it :)

--
"Great artists are extremely selfish and arrogant things" — Steven Wilson,
Porcupine Tree


 
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.
Isaac Johnston  
View profile  
 More options Jan 26 2012, 2:42 pm
From: Isaac Johnston <isaac.johns...@gmail.com>
Date: Thu, 26 Jan 2012 11:42:44 -0800 (PST)
Local: Thurs, Jan 26 2012 2:42 pm
Subject: Re: Embedded resources in hal+json
I have written a JSON and XML parser recently in JavaScript and having
_embedded made the solution a lot simpler, more elegant and
performant. In this case the client does not know what transclusions
it is looking for, nor could it. Please keep the current design for
this.

Cheers,
Isaac

On Jan 26, 4:37 am, Mike Kelly <mikekelly...@gmail.com> wrote:


 
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.
Steve Michelotti  
View profile  
 More options Jan 26 2012, 5:56 pm
From: Steve Michelotti <steve.michelo...@gmail.com>
Date: Thu, 26 Jan 2012 14:56:06 -0800 (PST)
Local: Thurs, Jan 26 2012 5:56 pm
Subject: Re: Embedded resources in hal+json
@Isaac - Is your parser open source?

On Jan 26, 2:42 pm, Isaac Johnston <isaac.johns...@gmail.com> wrote:


 
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.
Isaac Johnston  
View profile  
 More options Jan 26 2012, 7:16 pm
From: Isaac Johnston <isaac.johns...@gmail.com>
Date: Thu, 26 Jan 2012 16:16:59 -0800 (PST)
Local: Thurs, Jan 26 2012 7:16 pm
Subject: Re: Embedded resources in hal+json
On Jan 27, 11:56 am, Steve Michelotti <steve.michelo...@gmail.com>
wrote:

> @Isaac - Is your parser open source?

Sorry but no.

Cheers,
Isaac


 
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.
End of messages
« Back to Discussions « Newer topic     Older topic »