<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments for Ben Longden</title>
	<atom:link href="http://nocarrier.co.uk/comments/feed/" rel="self" type="application/rss+xml" />
	<link>http://nocarrier.co.uk</link>
	<description>PHP and some other bits...</description>
	<lastBuildDate>Sat, 28 Apr 2012 15:03:15 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>Comment on JSON Sucks by blongden</title>
		<link>http://nocarrier.co.uk/2012/04/json-sucks/comment-page-1/#comment-892</link>
		<dc:creator>blongden</dc:creator>
		<pubDate>Sat, 28 Apr 2012 15:03:15 +0000</pubDate>
		<guid isPermaLink="false">http://nocarrier.co.uk/?p=159#comment-892</guid>
		<description>@Jon

1) Yes there&#039;s better ways of handling multi lang (I would go for the Accept-Language / Content-Language HTTP headers in an API response like this - your suggestion of using the URI is fairly common in websites too (but using the preferred language setting in the browser included in the header I think is cleaner). The language example above was only really to show where JSON ends up being changed quite a lot, and XML stays almost the same in structure.

2) I&#039;m not sure I agree. If you gzip your response (and you should) you&#039;re going to get down to a fairly comparable size whether it&#039;s JSON or XML. Do agree that for multi lang though, the decision of what language to present *should* happen on the server, rather than in the client.

3) Depends. For simple structures, not really. When you start getting more complicated (arrays of objects in arrays etc) the fact that XML is just a more expressive format means that you have fewer lines to traverse, so it can actually make it easier to understand.</description>
		<content:encoded><![CDATA[<p>@Jon</p>
<p>1) Yes there&#8217;s better ways of handling multi lang (I would go for the Accept-Language / Content-Language HTTP headers in an API response like this &#8211; your suggestion of using the URI is fairly common in websites too (but using the preferred language setting in the browser included in the header I think is cleaner). The language example above was only really to show where JSON ends up being changed quite a lot, and XML stays almost the same in structure.</p>
<p>2) I&#8217;m not sure I agree. If you gzip your response (and you should) you&#8217;re going to get down to a fairly comparable size whether it&#8217;s JSON or XML. Do agree that for multi lang though, the decision of what language to present *should* happen on the server, rather than in the client.</p>
<p>3) Depends. For simple structures, not really. When you start getting more complicated (arrays of objects in arrays etc) the fact that XML is just a more expressive format means that you have fewer lines to traverse, so it can actually make it easier to understand.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JSON Sucks by blongden</title>
		<link>http://nocarrier.co.uk/2012/04/json-sucks/comment-page-1/#comment-891</link>
		<dc:creator>blongden</dc:creator>
		<pubDate>Sat, 28 Apr 2012 14:55:30 +0000</pubDate>
		<guid isPermaLink="false">http://nocarrier.co.uk/?p=159#comment-891</guid>
		<description>@Remon: Ok you can hack your way around the problem - but the fact remains that you&#039;re hands are very much more tied when you use JSON. What if you needed to add two or three chunks of data instead of just one? Yes you could flatten it all out but then your representation becomes clunky and difficult to work with. What if you have a variable number of items that you would normally represent in an array? It makes it more difficult for your client to parse if it&#039;s all flattened out in the root object. Not very nice.</description>
		<content:encoded><![CDATA[<p>@Remon: Ok you can hack your way around the problem &#8211; but the fact remains that you&#8217;re hands are very much more tied when you use JSON. What if you needed to add two or three chunks of data instead of just one? Yes you could flatten it all out but then your representation becomes clunky and difficult to work with. What if you have a variable number of items that you would normally represent in an array? It makes it more difficult for your client to parse if it&#8217;s all flattened out in the root object. Not very nice.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JSON Sucks by Jon</title>
		<link>http://nocarrier.co.uk/2012/04/json-sucks/comment-page-1/#comment-887</link>
		<dc:creator>Jon</dc:creator>
		<pubDate>Sat, 28 Apr 2012 13:25:35 +0000</pubDate>
		<guid isPermaLink="false">http://nocarrier.co.uk/?p=159#comment-887</guid>
		<description>Interesting. You got me thinking about how XML seems to have dropped off the charts for APIs  Some things I thought of:

1) Re multilingual APIs. One option is to simply make the lang part of the URI (eg app.com/api/en/users/1 and app.com/api/de/users/1). I would argue that this could be a better design - coming from Symfony2 background where it encourages us to make the locale part of te URI. 

2) I think in many cases JSON will result in smaller responses which is important when bandwidth is a concern. Also, by doing 1), you reduce the response size too. 

3) Personally I actually think JSON is easier to read. Do you really think the XML is easier?

Cheers, Jon</description>
		<content:encoded><![CDATA[<p>Interesting. You got me thinking about how XML seems to have dropped off the charts for APIs  Some things I thought of:</p>
<p>1) Re multilingual APIs. One option is to simply make the lang part of the URI (eg app.com/api/en/users/1 and app.com/api/de/users/1). I would argue that this could be a better design &#8211; coming from Symfony2 background where it encourages us to make the locale part of te URI. </p>
<p>2) I think in many cases JSON will result in smaller responses which is important when bandwidth is a concern. Also, by doing 1), you reduce the response size too. </p>
<p>3) Personally I actually think JSON is easier to read. Do you really think the XML is easier?</p>
<p>Cheers, Jon</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JSON Sucks by Remon van de Kamp</title>
		<link>http://nocarrier.co.uk/2012/04/json-sucks/comment-page-1/#comment-886</link>
		<dc:creator>Remon van de Kamp</dc:creator>
		<pubDate>Sat, 28 Apr 2012 13:16:25 +0000</pubDate>
		<guid isPermaLink="false">http://nocarrier.co.uk/?p=159#comment-886</guid>
		<description>So how about 

&lt;pre lang=&quot;javascript&quot;&gt;
{
    &quot;error&quot;: {
        &quot;id&quot;: 6,
        &quot;message&quot;: &quot;Something bad happened&quot;,
        &quot;message_de&quot;: &quot;Something bad happened (in German)&quot;
    }
}
&lt;/pre&gt;

Doesn&#039;t force any old clients to update anything either. New users can just suffix the language code to the field(s) that is/are translated.
I&#039;m pretty sure most people can live with the fact that the primary language (en) of the JSON is omitted since English is pretty much the defacto standard for any API.</description>
		<content:encoded><![CDATA[<p>So how about</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span>
    <span style="color: #3366CC;">&quot;error&quot;</span><span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #339933;">:</span> <span style="color: #CC0000;">6</span><span style="color: #339933;">,</span>
        <span style="color: #3366CC;">&quot;message&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Something bad happened&quot;</span><span style="color: #339933;">,</span>
        <span style="color: #3366CC;">&quot;message_de&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;Something bad happened (in German)&quot;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Doesn&#8217;t force any old clients to update anything either. New users can just suffix the language code to the field(s) that is/are translated.<br />
I&#8217;m pretty sure most people can live with the fact that the primary language (en) of the JSON is omitted since English is pretty much the defacto standard for any API.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The error hypermedia type by Distributed Weekly 152 &#8212; Scott Banwart&#039;s Blog</title>
		<link>http://nocarrier.co.uk/2012/04/the-error-hypermedia-type/comment-page-1/#comment-881</link>
		<dc:creator>Distributed Weekly 152 &#8212; Scott Banwart&#039;s Blog</dc:creator>
		<pubDate>Fri, 27 Apr 2012 13:43:21 +0000</pubDate>
		<guid isPermaLink="false">http://nocarrier.co.uk/?p=156#comment-881</guid>
		<description>[...] The error hypermedia type [...]</description>
		<content:encoded><![CDATA[<p>[...] The error hypermedia type [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JSON Sucks by Niko Nevala</title>
		<link>http://nocarrier.co.uk/2012/04/json-sucks/comment-page-1/#comment-879</link>
		<dc:creator>Niko Nevala</dc:creator>
		<pubDate>Thu, 26 Apr 2012 22:32:23 +0000</pubDate>
		<guid isPermaLink="false">http://nocarrier.co.uk/?p=159#comment-879</guid>
		<description>Nice article.

My other two pet peeves with JSON are: 1) that &lt;b&gt;it is (unnecessarily) difficult to validate&lt;/b&gt;, especially when compared to XML, and 2) that (for PHP, anyway) there is a &lt;b&gt;distinct lack of stream parsers&lt;/b&gt; available for it.

Obviously, these so-called problems are easily solved by not validating your API I/O and just increasing the memory limit for your PHP processes...</description>
		<content:encoded><![CDATA[<p>Nice article.</p>
<p>My other two pet peeves with JSON are: 1) that <b>it is (unnecessarily) difficult to validate</b>, especially when compared to XML, and 2) that (for PHP, anyway) there is a <b>distinct lack of stream parsers</b> available for it.</p>
<p>Obviously, these so-called problems are easily solved by not validating your API I/O and just increasing the memory limit for your PHP processes&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on JSON Sucks by Matthew Turland</title>
		<link>http://nocarrier.co.uk/2012/04/json-sucks/comment-page-1/#comment-877</link>
		<dc:creator>Matthew Turland</dc:creator>
		<pubDate>Thu, 26 Apr 2012 22:06:48 +0000</pubDate>
		<guid isPermaLink="false">http://nocarrier.co.uk/?p=159#comment-877</guid>
		<description>&lt;blockquote&gt;&quot;It probably isn&#039;t.&quot;&lt;/blockquote&gt;

Especially not if you&#039;re using Java! :P</description>
		<content:encoded><![CDATA[<blockquote><p>&#8220;It probably isn&#8217;t.&#8221;</p></blockquote>
<p>Especially not if you&#8217;re using Java! :P</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The error hypermedia type by blongden</title>
		<link>http://nocarrier.co.uk/2012/04/the-error-hypermedia-type/comment-page-1/#comment-874</link>
		<dc:creator>blongden</dc:creator>
		<pubDate>Thu, 26 Apr 2012 12:38:31 +0000</pubDate>
		<guid isPermaLink="false">http://nocarrier.co.uk/?p=156#comment-874</guid>
		<description>Actually the intention is that con-neg *should* be used for the language negotiation. It&#039;s just xml that can support multi lang using the xml:lang attribute and I wanted a way of representing the same thing in JSON (somewhat unsuccessfully IMO, blog post to follow about this subject!).

I&#039;m tempted to back out that facility in JSON to remove complexity from the format and just leave it as an option in the XML representation (and primarily use con-neg for it).

My thinking behind having it is incase the server blows up (5xx response) before the con-neg has complete - but perhaps it&#039;s over thinking it.</description>
		<content:encoded><![CDATA[<p>Actually the intention is that con-neg *should* be used for the language negotiation. It&#8217;s just xml that can support multi lang using the xml:lang attribute and I wanted a way of representing the same thing in JSON (somewhat unsuccessfully IMO, blog post to follow about this subject!).</p>
<p>I&#8217;m tempted to back out that facility in JSON to remove complexity from the format and just leave it as an option in the XML representation (and primarily use con-neg for it).</p>
<p>My thinking behind having it is incase the server blows up (5xx response) before the con-neg has complete &#8211; but perhaps it&#8217;s over thinking it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The error hypermedia type by Michael Stillwell</title>
		<link>http://nocarrier.co.uk/2012/04/the-error-hypermedia-type/comment-page-1/#comment-872</link>
		<dc:creator>Michael Stillwell</dc:creator>
		<pubDate>Wed, 25 Apr 2012 19:26:39 +0000</pubDate>
		<guid isPermaLink="false">http://nocarrier.co.uk/?p=156#comment-872</guid>
		<description>Sorry I guess my comment wasn&#039;t clear. The point about the large number of mime types is not that an error type is one too many, but that pretty much every one of the existing types could be rejected by a server in a way specific to that type. You might even want different error content types for the same input type: if an XML file is rejected, the server might send different error content types depending on whether it used libxml2 or xerces to do the validation.  (And obviously the client could use content negotiation to indicate that it would prefer xerces-style errors, etc.--maybe it was written before libxml2 was invented, for example.)

Regarding the recent addition of multiple languages within the response, why not handle that via content negotiation on Accept-Language, etc.?</description>
		<content:encoded><![CDATA[<p>Sorry I guess my comment wasn&#8217;t clear. The point about the large number of mime types is not that an error type is one too many, but that pretty much every one of the existing types could be rejected by a server in a way specific to that type. You might even want different error content types for the same input type: if an XML file is rejected, the server might send different error content types depending on whether it used libxml2 or xerces to do the validation.  (And obviously the client could use content negotiation to indicate that it would prefer xerces-style errors, etc.&#8211;maybe it was written before libxml2 was invented, for example.)</p>
<p>Regarding the recent addition of multiple languages within the response, why not handle that via content negotiation on Accept-Language, etc.?</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on The error hypermedia type by blongden</title>
		<link>http://nocarrier.co.uk/2012/04/the-error-hypermedia-type/comment-page-1/#comment-871</link>
		<dc:creator>blongden</dc:creator>
		<pubDate>Wed, 25 Apr 2012 09:22:09 +0000</pubDate>
		<guid isPermaLink="false">http://nocarrier.co.uk/?p=156#comment-871</guid>
		<description>Michael, you&#039;re probably right in that there are too many mime types around. The problem is that none of them are designed for specifically representing an error state. There was some consideration in including an application specific error code as a code element in the spec, however it conflicts with the HTTP status header. If you want your application to be more verbose in it&#039;s error responses it&#039;s perfectly ok to use a custom HTTP status code for that purpose if there is not already one suitable in all of the various RFC&#039;s out there. &lt;a href=&quot;http://en.wikipedia.org/wiki/List_of_HTTP_status_codes&quot; title=&quot;Wikipedia&quot; rel=&quot;nofollow&quot;&gt;Wikipedia&lt;/a&gt; has a pretty good list.

The vnd namespace is a lot more relaxed on the peer review aspect of getting the mime type approved. It&#039;s not been discussed on the ietf-types mailing list (but i&#039;ll drop a post in there). The spec is in draft form, and there are several changes and enhancements on the way already. If you have any suggestions then please do let me know.</description>
		<content:encoded><![CDATA[<p>Michael, you&#8217;re probably right in that there are too many mime types around. The problem is that none of them are designed for specifically representing an error state. There was some consideration in including an application specific error code as a code element in the spec, however it conflicts with the HTTP status header. If you want your application to be more verbose in it&#8217;s error responses it&#8217;s perfectly ok to use a custom HTTP status code for that purpose if there is not already one suitable in all of the various RFC&#8217;s out there. <a href="http://en.wikipedia.org/wiki/List_of_HTTP_status_codes" title="Wikipedia" rel="nofollow">Wikipedia</a> has a pretty good list.</p>
<p>The vnd namespace is a lot more relaxed on the peer review aspect of getting the mime type approved. It&#8217;s not been discussed on the ietf-types mailing list (but i&#8217;ll drop a post in there). The spec is in draft form, and there are several changes and enhancements on the way already. If you have any suggestions then please do let me know.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
<!-- This Quick Cache file was built for (  nocarrier.co.uk/comments/feed/ ) in 0.17802 seconds, on May 19th, 2012 at 9:38 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on May 19th, 2012 at 10:38 pm UTC -->
