Message from discussion
Response format for json api
Date: Tue, 23 Oct 2012 13:59:41 -0700 (PDT)
From: Frode Rosand <fr...@rosand.net>
To: api-craft@googlegroups.com
Message-Id: <5bfd581e-4c53-4645-943e-157e950975c3@googlegroups.com>
In-Reply-To: <F3E0507C-B221-437B-A9D6-529283CB4FA5@gmail.com>
References: <de5f1236-323c-4185-890f-02475d9de4a4@googlegroups.com> <CAPW_8m7BH82XCJRHK15HOt7dtk+-TXw6SyogxHQWgCD_ZyhUYw@mail.gmail.com> <53273BAB-88BA-4CD7-9C08-C8F95A287B3B@gmail.com> <CA+PG3aV6tTrRL40S5+Z9-7BCrb4u4azDOiHzpH=EnDzPOMHhEg@mail.gmail.com>
<F3E0507C-B221-437B-A9D6-529283CB4FA5@gmail.com>
Subject: Re: [api-craft] Response format for json api
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_1506_24426097.1351025981612"
------=_Part_1506_24426097.1351025981612
Content-Type: multipart/alternative;
boundary="----=_Part_1507_24502149.1351025981612"
------=_Part_1507_24502149.1351025981612
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Just a quick note on jQuery. It can access the status codes from the
response header and has been able to do so for a while.
Frode
On Sunday, October 21, 2012 1:17:37 PM UTC-7, mikeschinkel wrote:
>
> On Oct 21, 2012, at 8:26 AM, Live Flex <live...@gmail.com <javascript:>>
> wrote:
>
> Thanks for the reply Mike. I see a lot of value in that kind of response,
> although there is an argument that the code and status could be included in
> the header.
>
>
> On Oct 21, 2012, at 11:59 AM, Peter Williams <pe...@barelyenough.org<javascript:>>
> wrote:
>
> I don't like this approach. It obscures the most important parts of the
> representation with information that is best handled in the HTTP layer.
> Most HTTP libs these days are not broken and therefore allow easy access to
> the header info.
>
>
> If you watch the video[1] you'll see that Todd addresses the need around
> 4:30 saying that in jQuery AJAX you can't read the status code nor headers
> and he had at least one person in the audience agree that it is a problem.
>
> I post his example to the list because it seemed that others on this and
> the prior thread were collecting different approaches and I felt his
> approach had merit to be added to the list.
>
> If you really do have clients that are not able to access the response
> codes I'd prefer tucking that info away in a corner so that clients with
> less brain damage can ignore it. For example,
>
> {
> "address": "123 ...",
> // rest of data
> "_resp_metadata": {
> // for clients that use borked HTTP libs
> "code": 200,
> "status": "success"
> }
>
> I prefer Todd's approach because it puts the meta at the top level and
> then "real data" in the "data" property. Nothing obscures the real data
> and if you just want the pure data you can easily grab just it. Not so if
> there is an embedded "_resp_metadata" or otherwise named property. FWIW.
>
>
> -Mike
> [1] http://vimeo.com/channels/restfest/49614129
>
>
------=_Part_1507_24502149.1351025981612
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable
Just a quick note on jQuery. It can access the status codes from the respon=
se header and has been able to do so for a while.<div><br></div><div><br></=
div><div>Frode</div><div><br><br>On Sunday, October 21, 2012 1:17:37 PM UTC=
-7, mikeschinkel wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0=
;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div st=
yle=3D"word-wrap:break-word"><div><div>On Oct 21, 2012, at 8:26 AM, Live Fl=
ex <<a href=3D"javascript:" target=3D"_blank" gdf-obfuscated-mailto=3D"n=
BV3xnIhcwcJ">live...@gmail.com</a>> wrote:</div><blockquote type=3D"cite=
">Thanks for the reply Mike. I see a lot of value in that kind of response,=
although there is an argument that the code and status could be included i=
n the header.</blockquote><div><br></div><div><div>On Oct 21, 2012, at 11:5=
9 AM, Peter Williams <<a href=3D"javascript:" target=3D"_blank" gdf-obfu=
scated-mailto=3D"nBV3xnIhcwcJ">pe...@barelyenough.org</a>> wrote:</div><=
div><blockquote type=3D"cite">I don't like this approach. It obscures the m=
ost important parts of the representation with information that is best han=
dled in the HTTP layer. Most HTTP libs these days are not broken and theref=
ore allow easy access to the header info.</blockquote><br></div></div></div=
><blockquote style=3D"margin:0 0 0 40px;border:none;padding:0px"><div><div>=
<div>If you watch the video[1] you'll see that Todd addresses the need arou=
nd 4:30 saying that in jQuery AJAX you can't read the status code nor heade=
rs and he had at least one person in the audience agree that it is a proble=
m.</div></div></div><div><div><div><br></div></div></div><div><div><div>I p=
ost his example to the list because it seemed that others on this and the p=
rior thread were collecting different approaches and I felt his approach ha=
d merit to be added to the list.</div></div></div></blockquote><div><div><b=
lockquote type=3D"cite"><p dir=3D"ltr">If you really do have clients that a=
re not able to access the response codes I'd prefer tucking that info away =
in a corner so that clients with less brain damage can ignore it. For=
example,</p><p dir=3D"ltr"> {<br>  =
; "address": "123 ...",<br> // rest of =
data <br> "_resp_metadata": {<br> &=
nbsp; // for clients that use borked HTTP lib=
s<br> "code": 200,<br>  =
; "status": "success"<br> }=
</p></blockquote></div></div><blockquote style=3D"margin:0 0 0 40px;border:=
none;padding:0px"><div><div>I prefer Todd's approach because it puts the me=
ta at the top level and then "real data" in the "data" property. Nothing ob=
scures the real data and if you just want the pure data you can easily=
grab just it. Not so if there is an embedded "_resp_metadata" or oth=
erwise named property. FWIW.</div></div></blockquote><div><div><br></div>-M=
ike<br><div>[1] <a href=3D"http://vimeo.com/channels/restfest/49614129=
" target=3D"_blank">http://vimeo.com/channels/<wbr>restfest/49614129</a><br=
></div></div><br></div></blockquote></div>
------=_Part_1507_24502149.1351025981612--
------=_Part_1506_24426097.1351025981612--