Message from discussion
more on links
Received: by 10.66.79.105 with SMTP id i9mr347205pax.34.1352833784928;
Tue, 13 Nov 2012 11:09:44 -0800 (PST)
X-BeenThere: json-schema@googlegroups.com
Received: by 10.68.236.33 with SMTP id ur1ls30121056pbc.2.gmail; Tue, 13 Nov
2012 11:09:43 -0800 (PST)
Received: by 10.68.131.34 with SMTP id oj2mr6469626pbb.6.1352833783784;
Tue, 13 Nov 2012 11:09:43 -0800 (PST)
Date: Tue, 13 Nov 2012 11:09:43 -0800 (PST)
From: Ning <ningxiaop...@gmail.com>
To: json-schema@googlegroups.com
Message-Id: <58588933-f937-44ab-bcd6-da6961e2a80e@googlegroups.com>
In-Reply-To: <c29d71e8-55e3-48e6-badb-657342d3a112@googlegroups.com>
References: <cad70cb4-e0a2-4b12-b2b5-1f197e5cf2db@googlegroups.com>
<b366574e-4088-4ec3-aa95-947c58590a0b@googlegroups.com>
<7b3c7d01-b2c3-4ac9-af58-47c941aba468@googlegroups.com>
<1ce7fb9e-f729-4d46-aafe-055db0c3b984@googlegroups.com>
<d60c0260-4c94-4c37-88d9-b40b7776a808@googlegroups.com>
<5e903f2f-29cc-4c00-b00a-b4f552fa4a12@googlegroups.com>
<25e46308-9901-403d-9162-82d559b92683@googlegroups.com>
<b03e1c45-a388-4a38-b8d3-838f0b7d3e3e@googlegroups.com>
<c29d71e8-55e3-48e6-badb-657342d3a112@googlegroups.com>
Subject: Re: more on links
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_18_31750909.1352833783211"
------=_Part_18_31750909.1352833783211
Content-Type: multipart/alternative;
boundary="----=_Part_19_537002.1352833783215"
------=_Part_19_537002.1352833783215
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Thanks for helping me with this.
Is it possible to represent the instances links for lines and shipments? It
needs the parent id in the link, but I don't think we can use that kind of
URI templating there.
Ning
On Tuesday, November 13, 2012 3:09:21 AM UTC-8, Geraint (David) wrote:
>
> "Another disadvantage is that you can't (for example) insert a new line at
> the beginning of the order without messing everything up."
>
> Wow, my formatting is all over the place today - that was referring to
> Option #2.
>
> On Tuesday, 13 November 2012 10:49:50 UTC, Geraint (David) wrote:
>>
>> It sounds like what you want, however, is to be able to inspect a
>> shipment and see what line or order it came from. At this point, I can see
>> two options:
>>
>> *Option 1:*
>> You include the orderId and lineId inside every shipment object, and the
>> orderID inside the line objects. This makes your data bigger, and more
>> redundant, but gives you what you want - you can define the "self" and
>> "parent" links using these IDs.
>>
>> *Option 2:*
>> You instead address the shipments *by JSON Pointer fragment*. So if I
>> wanted to access the first shipment of the first line in an order, the
>> correct URI would be: /orders/123#/lines/0/shipments/0 - This also
>> means that you no longer need to assign unique line IDs or shipment IDs.
>> Every shipment would be identified by its position in the line, and that
>> line's position in the order header.
>>
>> One disadvantage of option 2 is that you can no longer download the
>> shipments individually. In order to look up the above data, the client
>> would have to download the whole of /orders/123, and use the fragment
>> part to locate the appropriate shipment. However, once it's done that, it
>> can do things like "look at the parent object of this shipment" instead of
>> relying on a parent link.
>>
>> *Option 3:*
>> The third option is what I described previously - change the URL so that
>> lines are at /lines/123 and shipments are at /shipments/123.
>>
>> *My opinion:*
>> Personally, I prefer option 1, for a couple of reasons:
>>
>> - You can fetch the shipments or lines individually (i.e. without
>> downloading the rest of the order)
>> - It allows more intuitive numbering of lines. For
>> human-friendliness, the first line in each header should be numbered 1 or
>> 0. But that means that lineId is not a unique key! However, if you
>> include the orderId in the line object, then the two keys together form a
>> unique key (orderId, lineId) which can be derived from the object.
>> - The order header object, and the line object are composite items -
>> they contain lots of other documents (with their own URIs) inside
>> themselves. I'm therefore more comfortable with redundancy here, because
>> the redundancy is "auto-generated" by the server, not stored - there is
>> therefore no issue of maintaining data integrity.
>> - It still keeps the URL scheme, which I like - it gives space for
>> intuitive listings like /orders/123/lines/1/shipments/ to see all
>> shipments in that line.
>>
>>
>> Another disadvantage is that you can't (for example) insert a new line at
>> the beginning of the order without messing everything up.
>>
>> On Tuesday, 13 November 2012 10:23:51 UTC, Geraint (David) wrote:
>>>
>>> OK - say you access a shipment via its URL, from the URI:
>>> /orders/123/lines/1/shipments/1
>>> {
>>> "shipmentId": 1,
>>> ...
>>> }
>>>
>>> There is no information in that object about the order or line it
>>> belongs to. It's just a shipment ID. At this point, you might as well
>>> just list it as /shipments/12345 instead.
>>>
>>> What is the benefit of including the order or the lines in the URI? It
>>> would be incredibly bad style for a client to inspect the URI and extract
>>> the order/line.
>>>
>>> On Monday, 12 November 2012 23:56:26 UTC, Ning wrote:
>>>
>>>> Thanks David.
>>>>
>>>> I am struggling with how I handle parent child, such as order header,
>>>> line, and shipment. An order line cannot exist outside a header. So we want
>>>> to make the URI something like:
>>>> /orders/123/lines/1/shipments/1
>>>>
>>>> In the schema, I want to do something like this:
>>>>
>>>> "orders": {
>>>> "properties": {
>>>> "orderId":...
>>>> "lines": {
>>>> "items": {
>>>> "properties": {
>>>> "lineId":...
>>>> "shipments": {
>>>> "items": {
>>>> "properties" {"shipmentId":...},
>>>> "links": [
>>>> {"rel": "self", "href":
>>>> "/orders/{orderId}/lines/{lineId}/shipments/{shipmentId}"}
>>>> ]
>>>> }
>>>> }
>>>> },
>>>> "links": [
>>>> {"rel": "self", "href": "/orders/{orderId}/lines/{lineId}"}
>>>> ]
>>>> }
>>>> }
>>>> },
>>>> "links":[
>>>> {
>>>> "rel": "self", "href": "/orders/{orderId}"
>>>> }
>>>> ]
>>>> }
>>>>
>>>> but this is not supported. Is there any alternative?
>>>> Can I reference the parent schema's self link from a child's schema?
>>>>
>>>>
>>>>
>>>> On Saturday, November 10, 2012 4:34:40 AM UTC-8, Geraint (David) wrote:
>>>>>
>>>>> 1. No - you can only reference the immediate properties of an object.
>>>>>
>>>>> 2. According to the version 3 specification, yes. I'm not sure I like
>>>>> it, though - to me, schemas should describe items. However, that's how
>>>>> draft version 3 was written, and I'm not going to try and change it if
>>>>> people find it useful.
>>>>>
>>>>> On Friday, November 9, 2012 8:27:30 PM UTC, Ning wrote:
>>>>>>
>>>>>> Thanks for the clarification.
>>>>>>
>>>>>> 1. Is it possible to reference the property from the parent schema
>>>>>> inside a nested schema's link? Take my previous example, if I expand it:
>>>>>>
>>>>>> "departments": {
>>>>>> "name": "Department",
>>>>>> "properties": {
>>>>>> "departmentId": ...,
>>>>>> "departmentName": ...,
>>>>>>
>>>>>> "locationId": {
>>>>>>
>>>>>> "type": integer
>>>>>>
>>>>>> },
>>>>>>
>>>>>> "employees": {
>>>>>>
>>>>>> "items": {
>>>>>>
>>>>>> "properties": {...},
>>>>>>
>>>>>> "links": [
>>>>>>
>>>>>> {"rel": "location",
>>>>>>
>>>>>> "href": "/locations/{locationId}},
>>>>>>
>>>>>> ]
>>>>>>
>>>>>> }
>>>>>>
>>>>>> }
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> Is the location link valid?
>>>>>>
>>>>>> 2. Regarding the "instances" link. Using the above example, I can
>>>>>> have a link:
>>>>>> {"rel": "instances",
>>>>>> "href": "/departments"}
>>>>>> for the department schema, and GET /departments is supposed to return
>>>>>> a list of departments. Is it right?
>>>>>>
>>>>>> Thanks.
>>>>>>
>>>>>>
>>>>>> Ning
>>>>>>
>>>>>> On Friday, November 9, 2012 1:22:20 AM UTC-8, Geraint (David) wrote:
>>>>>>>
>>>>>>> A couple of things worth noting: The client is under no obligation
>>>>>>> to believe that the data for the furniture items at the same as the data
>>>>>>> from the claimed URI. It is a useful hint.
>>>>>>>
>>>>>>> Also, the "self" link is only used because the *complete data* for
>>>>>>> the items of furniture is included, so the client only needs to make one
>>>>>>> request. If you only included a small portion of it, then a "full" link
>>>>>>> would be more appropriate, indicating that the client should visit that URI
>>>>>>> to get the rest of the data.
>>>>>>>
>>>>>>> On Friday, November 9, 2012 9:18:39 AM UTC, Geraint (David) wrote:
>>>>>>>>
>>>>>>>> The "self" link is often not very useful if you have just fetched
>>>>>>>> the document from that URI. As you say, you already have the URI, so what
>>>>>>>> does the "self" link provide?
>>>>>>>>
>>>>>>>> However, it is more useful when you opened the data from somewhere
>>>>>>>> else, and do *not* know the URI for it. In that case, the "self"
>>>>>>>> link is just a way of specifying that URI from the item data.
>>>>>>>>
>>>>>>>> It's also useful when you have composite data. For instance, say
>>>>>>>> we have this document fetched from /rooms/4:
>>>>>>>> {
>>>>>>>> "roomId": 4,
>>>>>>>> "name": "The lobby",
>>>>>>>> "furniture": [
>>>>>>>> {
>>>>>>>> "furnitureId": 3563,
>>>>>>>> "roomId": 4,
>>>>>>>> "name": "Receptionist's desk",
>>>>>>>> "type": "desk",
>>>>>>>> ...
>>>>>>>> },
>>>>>>>> {
>>>>>>>> "furnitureId": 2031,
>>>>>>>> "roomId": 4,
>>>>>>>> "name": "A wheely chair",
>>>>>>>> "type": "chair",
>>>>>>>> ...
>>>>>>>> },
>>>>>>>> ]
>>>>>>>> }
>>>>>>>>
>>>>>>>> This document contains the *full* details of all the furniture in
>>>>>>>> that room, bundled up inside it. However, if I want to interact with a
>>>>>>>> particular piece of furniture, how do I do that? I could use a JSON
>>>>>>>> Pointer fragment, but then if I moved a piece of furniture from one room to
>>>>>>>> the other, nobody else could tell it was the same piece of furniture.
>>>>>>>>
>>>>>>>> So I define a "self" link on the furniture items:
>>>>>>>> {
>>>>>>>> "title": "Room",
>>>>>>>> "type": "object",
>>>>>>>> "properties": {
>>>>>>>> "furniture": {
>>>>>>>> "type": "array",
>>>>>>>> "items": {
>>>>>>>> "title": "Furniture",
>>>>>>>> "type": "object",
>>>>>>>> "properties": { ... },
>>>>>>>> "links": [
>>>>>>>> * {
>>>>>>>> *
>>>>>>>> * "rel": "self",
>>>>>>>> *
>>>>>>>> * "href": "/furniture/{furnitureId}"
>>>>>>>> *
>>>>>>>> * },
>>>>>>>> *
>>>>>>>> {
>>>>>>>> "rel": "parent",
>>>>>>>> "href": "/room/{roomId}"
>>>>>>>> }
>>>>>>>> ]
>>>>>>>> }
>>>>>>>> }
>>>>>>>> }
>>>>>>>> }
>>>>>>>>
>>>>>>>> Now, if I want to move the wheely chair to another room, I don't
>>>>>>>> have to delete the one in the lobby, and create a new one somewhere else,
>>>>>>>> because this chair has a unique URI of its own. And what's more, I
>>>>>>>> *know* this URI, even though it was served up to me embedded
>>>>>>>> inside another document.
>>>>>>>>
>>>>>>>> So I can probably just modify the chair itself using a PUT request:
>>>>>>>> PUT /furniture/2031
>>>>>>>> {
>>>>>>>> "furnitureId": 2031,
>>>>>>>> "roomId": 15,
>>>>>>>> "name": "The wheely chair from the lobby",
>>>>>>>> "type": "chair",
>>>>>>>> ...
>>>>>>>> }
>>>>>>>>
>>>>>>>> Presumably, the server would at this point stop including the chair
>>>>>>>> in the furniture listing for the lobby (#4), and start including it in a
>>>>>>>> different room (#15).
>>>>>>>>
>>>>>>>> On Thursday, November 8, 2012 11:30:35 PM UTC, Ning wrote:
>>>>>>>>>
>>>>>>>>> I am trying to figure out how to use the links for rest APIs.
>>>>>>>>>
>>>>>>>>> Suppose that I have a resource /departments and /departments/123
>>>>>>>>> lets me access a particular department 123.
>>>>>>>>>
>>>>>>>>> How will be the self link used by a consumer? say if I have:
>>>>>>>>>
>>>>>>>>> "departments": {
>>>>>>>>> "name": "Department",
>>>>>>>>> "properties": {
>>>>>>>>> "departmentId": {
>>>>>>>>> "type": "integer",
>>>>>>>>> "description": "department identifier"
>>>>>>>>> },
>>>>>>>>> "departmentName": {
>>>>>>>>> "type": "string",
>>>>>>>>> "description": "department name"
>>>>>>>>> }
>>>>>>>>> }
>>>>>>>>> "links": [
>>>>>>>>> {
>>>>>>>>> "rel": "self",
>>>>>>>>> "href": "{departmentId}"
>>>>>>>>> }
>>>>>>>>> ]
>>>>>>>>> }
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> The self link is against a json instance, so I should already have
>>>>>>>>> the instance URI, which is /departments/123. What does the self link
>>>>>>>>> provide?
>>>>>>>>>
>>>>>>>>
------=_Part_19_537002.1352833783215
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Thanks for helping me with this.<div><br></div><div>Is it possible to repre=
sent the instances links for lines and shipments? It needs the parent id in=
the link, but I don't think we can use that kind of URI templating there.<=
/div><div><br></div><div><br></div><div>Ning</div><div><br>On Tuesday, Nove=
mber 13, 2012 3:09:21 AM UTC-8, Geraint (David) wrote:<blockquote class=3D"=
gmail_quote" style=3D"margin: 0;margin-left: 0.8ex;border-left: 1px #ccc so=
lid;padding-left: 1ex;">"Another disadvantage is that you can't (for exampl=
e) insert a new line at the beginning of the order without messing everythi=
ng up."<div><br></div><div>Wow, my formatting is all over the place today -=
that was referring to Option #2.<br><br>On Tuesday, 13 November 2012 10:49=
:50 UTC, Geraint (David) wrote:<blockquote class=3D"gmail_quote" style=3D"=
margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">It =
sounds like what you want, however, is to be able to inspect a shipment and=
see what line or order it came from. At this point, I can see two op=
tions:<div><br></div><div><u>Option 1:</u></div><div>You include the orderI=
d and lineId inside every shipment object, and the orderID inside the line =
objects. This makes your data bigger, and more redundant, but gives y=
ou what you want - you can define the "self" and "parent" links using these=
IDs.</div><div><br></div><div><u>Option 2:</u></div><div>You instead addre=
ss the shipments <i>by JSON Pointer fragment</i>. So if I wanted to a=
ccess the first shipment of the first line in an order, the correct URI wou=
ld be: <font face=3D"courier new, monospace">/orders/123#/lines/0/<wbr>ship=
ments/0</font><font face=3D"arial, sans-serif"> - This also means tha=
t you no longer need to assign unique line IDs or shipment IDs. Every=
shipment would be identified by its position in the line, and that line's =
position in the order header.</font></div><div><br></div><div>One disadvant=
age of option 2 is that you can no longer download the shipments individual=
ly. In order to look up the above data, the client would have to down=
load the whole of <font face=3D"courier new, monospace">/orders/123</font>,=
and use the fragment part to locate the appropriate shipment. Howeve=
r, once it's done that, it can do things like "look at the parent object of=
this shipment" instead of relying on a parent link.</div><div><br></div><d=
iv><u>Option 3:</u></div><div>The third option is what I described previous=
ly - change the URL so that lines are at <font face=3D"courier new, monospa=
ce">/lines/123</font> and shipments are at <font face=3D"courier new, monos=
pace">/shipments/123</font>.</div><div><br></div><div><u>My opinion:</u></d=
iv><div>Personally, I prefer option 1, for a couple of reasons:</div><div><=
ul><li><span style=3D"line-height:normal">You can fetch the shipments or li=
nes individually (i.e. without downloading the rest of the order)</span></l=
i><li><span style=3D"line-height:normal">It allows more intuitive numbering=
of lines. For human-friendliness, the first line in each header shou=
ld be numbered 1 or 0. But that means that lineId is not a unique key=
! However, if you include the orderId in the line object, then the tw=
o keys together form a unique key (orderId, lineId) which can be derived fr=
om the object.<br></span></li><li><span style=3D"line-height:normal">The or=
der header object, and the line object are composite items - they contain l=
ots of other documents (with their own URIs) inside themselves. I'm t=
herefore more comfortable with redundancy here, because the redundancy is "=
auto-generated" by the server, not stored - there is therefore no issue of =
maintaining data integrity.</span></li><li><span style=3D"line-height:norma=
l">It still keeps the URL scheme, which I like - it gives space for intuiti=
ve listings like <font face=3D"courier new, monospace">/orders/123/lines/1/=
shipments/</font> to see all shipments in that line.</span></li></ul></div>=
<div><br></div><div>Another disadvantage is that you can't (for example) in=
sert a new line at the beginning of the order without messing everything up=
.<br></div><div><div><div><br>On Tuesday, 13 November 2012 10:23:51 UTC, Ge=
raint (David) wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;ma=
rgin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">OK - say you a=
ccess a shipment via its URL, from the URI:<font face=3D"courier new, monos=
pace"> /orders/123/lines/1/<wbr>shipments/1</font><div><font face=3D"c=
ourier new, monospace">{</font></div><div><font face=3D"courier new, monosp=
ace"> "shipmentId": 1,</font></div><div><font face=3D"courier =
new, monospace"> ...</font></div><div><font face=3D"courier ne=
w, monospace">}</font></div><div><br></div><div>There is no information in =
that object about the order or line it belongs to. It's just a shipme=
nt ID. At this point, you might as well just list it as <font face=3D=
"courier new, monospace">/shipments/12345</font> instead.</div><div><br></d=
iv><div>What is the benefit of including the order or the lines in the URI?=
It would be incredibly bad style for a client to inspect the URI and=
extract the order/line.</div><div><br></div><div>On Monday, 12 November 20=
12 23:56:26 UTC, Ning wrote:<br></div><div><blockquote class=3D"gmail_quot=
e" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-l=
eft:1ex">Thanks David.<div><br></div><div>I am struggling with how I handle=
parent child, such as order header, line, and shipment. An order line cann=
ot exist outside a header. So we want to make the URI something like:</div>=
<div>/orders/123/lines/1/shipments/<wbr>1</div><div><br></div><div>In the s=
chema, I want to do something like this:</div><div><br></div><div>"orders":=
{</div><div> "properties": {</div><div> "orderId":...</=
div><div> "lines": {</div><div> "items": {=
</div><div> "properties": {</div><div> &nb=
sp; "lineId":...</div><div> =
"shipments": {</div><div> =
"items": {</div><div> =
"properties" {"shipmentId":...},</div><div> &nbs=
p; "links": [</div><div> &nb=
sp; {"rel": "self", "href": "/orders/{ord=
erId}/lines/{<wbr>lineId}/shipments/{shipmentId}<wbr>"}</div><div> &n=
bsp; ]</div><div> &nb=
sp; }</div><div> &nbs=
p; }</div><div> },</div><div> =
"links": [</div><div> &nbs=
p;{"rel": "self", "href": "/orders/{orderId}/lines/{<wbr>lineId}"}</div><di=
v> ]<br></div><div> }</div><=
div> }</div><div> },</div><div> "links":[</div><di=
v> {</div><div> "rel": "self", "href": "/o=
rders/{orderId}"</div><div> }</div><div> ]</div><d=
iv>}</div><div><br></div><div>but this is not supported. Is there any alter=
native?</div><div>Can I reference the parent schema's self link from a chil=
d's schema?</div><div><br></div><div><br><br>On Saturday, November 10, 2012=
4:34:40 AM UTC-8, Geraint (David) wrote:<blockquote class=3D"gmail_quote" =
style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left=
:1ex">1. No - you can only reference the immediate properties of an object.=
<div><br></div><div>2. According to the version 3 specification, yes.  =
;I'm not sure I like it, though - to me, schemas should describe items. &nb=
sp;However, that's how draft version 3 was written, and I'm not going to tr=
y and change it if people find it useful.</div><div><div><br>On Friday, Nov=
ember 9, 2012 8:27:30 PM UTC, Ning wrote:<blockquote class=3D"gmail_quote" =
style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left=
:1ex">Thanks for the clarification.<div><br></div><div>1. Is it possible to=
reference the property from the parent schema inside a nested schema's lin=
k? Take my previous example, if I expand it:</div><div><pre>"departments": =
{
"name": "Department",
"properties": {
"departmentId": ...,
"departmentName": ...,</pre><pre> "locationId": {</pre><pre> =
"type": integer</pre><pre> },</pre><pre> "employees": {</pre>=
<pre> "items": {</pre><pre> "properties": {...},</pre><pre>=
"links": [</pre><pre> {"rel": "location", </pre><=
pre> "href": "/locations/{locationId}},</pre><pre> ]</=
pre><pre> }</pre><pre> }
}
}</pre>Is the location link valid?</div><div><br></div><div>2. Regarding =
the "instances" link. Using the above example, I can have a link: </di=
v><div>{"rel": "instances",</div><div> "href": "/departments"}</div><d=
iv>for the department schema, and GET /departments is supposed to return a =
list of departments. Is it right?</div><div><br></div><div>Thanks.</div><di=
v><br></div><div><br></div><div>Ning</div><div><br>On Friday, November 9, 2=
012 1:22:20 AM UTC-8, Geraint (David) wrote:<blockquote class=3D"gmail_quot=
e" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-l=
eft:1ex">A couple of things worth noting: The client is under no obli=
gation to believe that the data for the furniture items at the same as=
the data from the claimed URI. It is a useful hint.<div><br></div><d=
iv>Also, the "self" link is only used because the <u>complete data</u> for =
the items of furniture is included, so the client only needs to make one re=
quest. If you only included a small portion of it, then a "full" link=
would be more appropriate, indicating that the client should visit that UR=
I to get the rest of the data.</div><div><br>On Friday, November 9, 2012 9:=
18:39 AM UTC, Geraint (David) wrote:<blockquote class=3D"gmail_quote" style=
=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex"=
>The "self" link is often not very useful if you have just fetched the docu=
ment from that URI. As you say, you already have the URI, so what doe=
s the "self" link provide?<div><br></div><div>However, it is more useful wh=
en you opened the data from somewhere else, and do <i>not</i> know the=
URI for it. In that case, the "self" link is just a way of specifyin=
g that URI from the item data.</div><div><br></div><div>It's also useful wh=
en you have composite data. For instance, say we have this document f=
etched from <font face=3D"'courier new', monospace">/rooms/4</font>:</=
div><div><font face=3D"'courier new', monospace">{</font></div><div><font f=
ace=3D"'courier new', monospace"> "roomId": 4,<br></font></div=
><div><font face=3D"'courier new', monospace"> "name": "The lo=
bby",<br></font></div><div><font face=3D"'courier new', monospace"> &=
nbsp; "furniture": [<br></font></div><div><font face=3D"'courier new', mono=
space"> {<br></font></div><div><font face=3D"'co=
urier new', monospace"> "furniture=
Id": 3563,<br></font></div><div><font face=3D"'courier new', monospace">&nb=
sp; "roomId": 4,<br></font></div><div><s=
pan style=3D"font-family:'courier new',monospace"> &nbs=
p; "name": "Receptionist's desk",</span><br></div><div><font =
face=3D"'courier new', monospace"> =
"type": "desk",</font></div><div><font face=3D"'courier new', monospace">&=
nbsp; ...<br></font></div><div=
><font face=3D"'courier new', monospace"> }=
,<br></font></div><div><font face=3D"'courier new', monospace">  =
; {<br></font></div><div><font face=3D"'courier new', monospa=
ce"> "furnitureId": 2031=
,<br></font></div><div><font face=3D"'courier new', monospace">  =
; "roomId": 4,<br></font></div><div><font face=
=3D"'courier new', monospace"> =
"name": "A wheely chair",<br></font></div><div><font face=3D"'courie=
r new', monospace"> "typ=
e": "chair",<br></font></div><div><font face=3D"'courier new', monospace">&=
nbsp; ...<br></font></div><div=
><font face=3D"'courier new', monospace"> }=
,<br></font></div><div><font face=3D"'courier new', monospace">  =
; ]<br></font></div><div><font face=3D"'courier new', monospace">}</font><b=
r><br>This document contains the <i>full</i> details of all the furnit=
ure in that room, bundled up inside it. However, if I want to interac=
t with a particular piece of furniture, how do I do that? I could use=
a JSON Pointer fragment, but then if I moved a piece of furniture from one=
room to the other, nobody else could tell it was the same piece of furnitu=
re.</div><div><br></div><div>So I define a "self" link on the furniture ite=
ms:</div><div><font face=3D"'courier new', monospace">{</font></div><div><f=
ont face=3D"'courier new', monospace"> "title": "Room",</font>=
</div><div><font face=3D"'courier new', monospace"> "type=
": "object",</font></div><div><font face=3D"'courier new', monospace"> =
; "properties": {<br></font></div><div><font face=3D"'courier n=
ew', monospace"> "furniture": {<br></f=
ont></div><div><font face=3D"'courier new', monospace"> &=
nbsp; "type": "array",<br></font></div><div>=
<font face=3D"'courier new', monospace"> &nb=
sp; "items": {<br></font></div><div><font face=3D"'courie=
r new', monospace">  =
; "title": "Furniture",<br></font></div><div><font face=
=3D"'courier new', monospace"> =
"type": "object",<br></font></div><div><font=
face=3D"'courier new', monospace"> &n=
bsp; "properties": { ... },<br></font></div>=
<div><font face=3D"'courier new', monospace"> &nbs=
p; "links": [<br></font></div><d=
iv><font face=3D"'courier new', monospace"><b> &=
nbsp; {<br></b></font></div><div><font f=
ace=3D"'courier new', monospace"><b> &=
nbsp; =
"rel": "self",<br></b></font></div><div><font face=3D"'courier new', monosp=
ace"><b> &nb=
sp; "href": "/furniture/{furnitu=
reId}"<br></b></font></div><div><font face=3D"'courier new', monospace"><b>=
 =
; },<br></b></font></div><div><font face=3D"'courier new'=
, monospace"> =
{<br></font></div><div><font face=3D"'courier new', monospace">&nbs=
p; &nb=
sp; "rel": "parent",<br></font></div><div><f=
ont face=3D"'courier new', monospace">  =
; &nbs=
p;"href": "/room/{roomId}"<br></font></div><div><font face=3D"'courier new'=
, monospace">  =
; }<br></font></div><div><font face=3D"'cour=
ier new', monospace"> &nb=
sp; ]<br></font></div><div><font face=3D"'courier new', m=
onospace"> }<br></f=
ont></div><div><font face=3D"'courier new', monospace"> &=
nbsp; }<br></font></div><div><font face=3D"'courier new', monos=
pace"> }<br></font></div><div><font face=3D"'courier new'=
, monospace">}</font><br></div><div><br></div><div>Now, if I want to move t=
he wheely chair to another room, I don't have to delete the one in the lobb=
y, and create a new one somewhere else, because this chair has a unique URI=
of its own. And what's more, I <i>know</i> this URI, even thoug=
h it was served up to me embedded inside another document.</div><div><br></=
div><div>So I can probably just modify the chair itself using a PUT request=
:</div><div><font face=3D"'courier new', monospace">PUT /furniture/2031</fo=
nt></div><div><span style=3D"font-family:'courier new',monospace">{</span><=
br></div><div><font face=3D"'courier new', monospace"> "furnit=
ureId": 2031,<br></font></div><div><font face=3D"'courier new', monospace">=
"roomId": 15,<br></font></div><div><font face=3D"'courier new=
', monospace"> "name": "The wheely chair from the lobby",<br><=
/font></div><div><font face=3D"'courier new', monospace"> "typ=
e": "chair",<br></font></div><div><font face=3D"'courier new', monospace">&=
nbsp; ...<br></font></div><div><font face=3D"'courier new', monospac=
e">}<br></font></div><div><br></div><div>Presumably, the server would at th=
is point stop including the chair in the furniture listing for the lobby (#=
4), and start including it in a different room (#15).</div><div><br>On Thur=
sday, November 8, 2012 11:30:35 PM UTC, Ning wrote:<blockquote class=3D"gma=
il_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;pa=
dding-left:1ex">I am trying to figure out how to use the links for rest API=
s.<br><br>Suppose that I have a resource /departments and /departments/123 =
lets me access a particular department 123.<br><br>How will be the self lin=
k used by a consumer? say if I have:<br><pre><span>"departments"</span>: {
<span>"name"</span>: <span>"Department"</span>,
<span>"properties"</span>: {
<span>"departmentId"</span>: {
<span>"type"</span>: <span>"integer"</span>,
<span>"description"</span>: <span>"department identifier"</span>
},
<span>"departmentName"</span>: {
<span>"type"</span>: <span>"string"</span>,
<span>"description"</span>: <span>"department name"</span>
}
}
<span>"links"</span>: [
{
<span>"rel"</span>: <span>"self"</span>,
<span>"href"</span>: <span>"{departmentId}"</span>
}
]
}</pre><br>The self link is against a json instance, so I should already =
have the instance URI, which is /departments/123. What does the self link p=
rovide?<br></blockquote></div></blockquote></div></blockquote></div></block=
quote></div></div></blockquote></div></blockquote></div></blockquote></div>=
</div></div></blockquote></div></blockquote></div>
------=_Part_19_537002.1352833783215--
------=_Part_18_31750909.1352833783211--