<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
    xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:wfw="http://wellformedweb.org/CommentAPI/"
    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/"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    >

<channel>
    <title>Webmonkey &#187; json</title>
    <atom:link href="http://www.webmonkey.com/tag/json/feed/" rel="self" type="application/rss+xml" />
    <link>http://www.webmonkey.com</link>
    <description>The Web Developer&#039;s Resource</description>
    <lastBuildDate>Fri, 05 Apr 2013 20:20:46 +0000</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <generator>http://wordpress.org/?v=3.4.2</generator>
    
    <item>
        <title>RSS in JSON, for Real?</title>
        <link>http://www.webmonkey.com/2012/09/rss-in-json-for-real/</link>
        <comments>http://www.webmonkey.com/2012/09/rss-in-json-for-real/#comments</comments>
        <pubDate>Tue, 11 Sep 2012 14:37:46 +0000</pubDate>

                <dc:creator>Dave Winer</dc:creator>

        <guid isPermaLink="false">http://www.webmonkey.com/?p=59038</guid>
        		<category><![CDATA[APIs]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Web Basics]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[RSS]]></category>
            <enclosure url="http://www.webmonkey.com/wp-content/uploads/2012/09/2443615609_8486476a2c_b-200x100.jpg" type="image/jpeg" length="48000" />
                    <description><![CDATA[<div class="rss_thumbnail"><img src="http://www.webmonkey.com/wp-content/uploads/2012/09/2443615609_8486476a2c_b-660x471.jpg" alt="RSS in JSON, for Real?" /></div>Dave Winer pioneered the development of syndication through RSS feeds; now he weighs in on how and why you might want to also distribute your RSS data in JSON, a format popular with today's web developers.]]></description>

            <content:encoded><![CDATA[<p><!-- wpautop enabled --><div id="attachment_59049" class="wp-caption aligncenter" style="width: 590px"><a href="http://www.webmonkey.com/wp-content/uploads/2012/09/2443615609_8486476a2c_b.jpg"><img src="http://www.webmonkey.com/wp-content/uploads/2012/09/2443615609_8486476a2c_b.jpg" alt="" title="2443615609_8486476a2c_b" width="580" class="size-full wp-image-59049" /></a><p class="wp-caption-text"><em>Photo: <a href="https://secure.flickr.com/photos/conboy/2443615609/">Kevin Conboy</a>/Flickr</em></p></div></p>
<p>A short while ago Twitter said they were going to move to JSON over XML, without much explanation other than they like JSON and not XML so much these days, etc. I&#8217;m a big believer that everyone has the right to support whatever they want when they want for whatever reason, whether they say the truth or not. Because of that belief, I take with a grain of salt every bit of support for every format and protocol. I assume that just because someone supports it today doesn&#8217;t tell you for sure that they will support it tomorrow. Though the penalty is usually pretty high for removing support for interfaces people depend on. They tend to remember it next time you ask for their trust. All that is fair game too.  </p>
<p>So anyway, this got me thinking again about the possibility that JSON might take over from XML. What then? Should we give up all the interop we get from RSS just because it uses XML and not JSON? And it&#8217;s because of all that interop that that day will never come. A transition may happen over a long period of time, and before it&#8217;s complete there will be something after JSON. Because smart people see that, they tend to be conservative about switching just for the sake of switching. It&#8217;s why the web, which is entirely an XML application, will keep XML support everywhere for the forseeable future. </p>
<p>In other words, I&#8217;d bet with virtual 100 percent certainty that it&#8217;s safe to keep producing XML-based RSS feeds.  </p>
<p>But people like JSON, there&#8217;s no denying that. And a JSONified RSS can totally co-exist with the original XML. So let&#8217;s have RSS in JSON? That&#8217;s a question that seems worth asking about, at this time. </p>
<p>Turns out it is a very straightforward thing to do. I of course have an RSS feed for Scripting News, the blog you&#8217;re reading right now. I wrote a script that maintains JSON and JSONP versions of the same content, automatically. When the RSS is built so are the JSON formats.  </p>
<p><a href="http://scripting.com/rss.json">http://scripting.com/rss.json</a> and <a href="http://scripting.com/rss.js">http://scripting.com/rss.js</a> </p>
<p>I learned a long time ago to embrace change. It&#8217;s why there is a RSS today that is derived from the RSS that Netscape shipped in 1999 and has features of my scriptingNews format shipped in 1997. If the world wants to go to JSON, help it get there in a way that benefits from all we learned in the evolution of RSS from 1997 through 2002. It&#8217;s stood up pretty well over the years. And there&#8217;s wide support for it, and lots of understanding of how it works. If there is to be a JSON-based syndication standard, we can cut years off the development process by simply accommodating it. </p>
<p>So I put together an invitation to discuss this.  </p>
<p><a href="http://rssjs.org/">http://rssjs.org/</a> </p>
<p>If you find this interesting, give it some thought, and if you have something to say, write a blog post of your own, or write a comment on that page. Obviously there&#8217;s no moderation for what goes on your blog, but there will be moderation of the comments. Be aware of that. One feature of the past are personal attacks which are totally pointless and subtract from the discourse, and we should not carry that practice forward. That&#8217;s why the moderation. :-) </p>
<p>Otherwise, I totally look forward to hearing what people think.  </p>
<p>Thanks&#8230; </p>
<p><em>This post first appeared on <a href="http://scripting.com/stories/2012/09/10/rssInJsonForReal.html">Scripting News</a>.</em></p>
<div class="bio"><a href="http://www.wired.com/epicenter/author/Dave"><img src="http://www.wired.com/epicenter/wp-content/gallery/biopics/dave_winer.jpg" alt="" /></a><a href="http://worldoutline.scripting.com/blogroll/aboutTheAuthor">Dave Winer</a>, a former researcher at NYU and Harvard, pioneered the development of weblogs, syndication (RSS), podcasting, outlining, and web content management software. A former contributing editor at <em>Wired</em> magazine, Dave won the Wired Tech Renegade award in 2001.<br /> Follow <a href="http://www.twitter.com/davewiner">@davewiner</a> on Twitter.</div>
<div id='linker_widget'></div>
<div id='linker_widget' class='contextly-widget'></div>]]></content:encoded>
            <wfw:commentRss>http://www.webmonkey.com/2012/09/rss-in-json-for-real/feed/</wfw:commentRss>
        <slash:comments>0</slash:comments>

        
    </item>
    
    <item>
        <title>Get Started With JSON</title>
        <link>http://www.webmonkey.com/2010/02/get_started_with_json/</link>
        <comments>http://www.webmonkey.com/2010/02/get_started_with_json/#comments</comments>
        <pubDate>Mon, 15 Feb 2010 20:45:47 +0000</pubDate>

                <dc:creator>Webmonkey Staff</dc:creator>

        <guid isPermaLink="false">http://stag.wired.com/primate/?p=838</guid>
        		<category><![CDATA[APIs]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[i javascript]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[wik]]></category>
        <description><![CDATA[JSON is a format for describing data that is easily converted to most programming languages. Many APIs, such as Flickr and Twitter, now offer their results in this format. The acronym JSON (pronounced like the name &#8220;Jason&#8221;) stands for JavaScript Object Notation. It&#8217;s a way of annotating data that&#8217;s relatively easy for humans to read [...]]]></description>

            <content:encoded><![CDATA[<!-- wpautop disabled --><p>JSON is a format for describing data that is easily converted to most programming languages. Many APIs, such as Flickr and Twitter, now offer their results in this format.

</p><p>The acronym JSON (pronounced like the name &#8220;Jason&#8221;) stands for JavaScript Object Notation. It&#8217;s a way of annotating data that&#8217;s relatively easy for humans to read and write. This helps explain its recent popularity. As Ajax applications, which depend heavily on JavaScript, have become common, programmers have searched for an easy way to transfer data. Converting JSON to something usable in JavaScript takes one line of code and automatically works in all browsers.</p>
<br />
<span id="more-838"></span>

<table id="toc" class="toc" summary="Contents"><tbody><tr><td><div id="toctitle"><h2>Contents</h2> </div>

<ol>



<li><a href="#A_Simple_Example:_A_List_of_Movies">A Simple Example: A List of Movies</a>

<ol>
<li><a href="#Creating_the_JavaScript_Object">Creating the JavaScript Object</a></li>
<li><a href="#Accessing_the_JavaScript_Object">Accessing the JavaScript Object</a></li>
</ol>
</li>
<li><a href="#Objects_with_More_Attributes:_A_Movie_Review">Objects with More Attributes: A Movie Review</a>
<ol>
<li><a href="#Creating_and_Accessing_the_JavaScript_Object">Creating and Accessing the JavaScript Object</a></li>
</ol>
</li>
<li><a href="#Combination_Example:_One_Movie_and_its_Many_Reviews">Combination Example: One Movie and its Many Reviews</a>
<ol>
<li><a href="#Creating_and_Accessing_the_JavaScript_Object_2">Creating and Accessing the JavaScript Object</a></li>
</ol>
</li>
<li><a href="#Using_JSON_with_Your_Favorite_Language">Using JSON with Your Favorite Language</a></li>
<li><a href="#APIs_that_Return_JSON">APIs that Return JSON</a></li>
</ol>
</td></tr></tbody></table>

<a name="A_Simple_Example:_A_List_of_Movies"></a><h2> <span class="mw-headline">A Simple Example: A List of Movies</span></h2>

<p>Let&#8217;s say we wanted to store the first five <i>Friday the 13th</i> movies (Jason? Get it?) for later access. In most programming languages, an array would be appropriate. Arrays hold an ordered collection of similar data.
</p><p>JSON includes a way to describe arrays. So, the JSON text might look like this:

</p>

<pre class="brush: js">{"movielist": ["Friday the 13th", "Friday the 13th Part 2", "Friday the 13th Part III", "Friday the 13th: The Final Chapter", "Friday the 13th: A New Beginning"]}

</pre>

<p>The squiggly brackets surround the entire object. Whereas an array holds a list in a certain order, an object is an unordered collection. Objects hold attributes that point to values. A value could be one number or a single line of text. Or, a value can be an array, like it is here.

</p><p>Our object has one attribute, named &#8220;movielist.&#8221; Attributes are in quotes, because they are a string (a fancy programming term for text) that holds the name of the attribute. After the quotes comes a colon, which separates the attribute from the value.

</p><p>The square brackets contain an array, which holds our ordered list of other values. This will make more sense when we see it in action.

</p><p><br />

</p>

<a name="Creating_the_JavaScript_Object"></a><h3> <span class="mw-headline">Creating the JavaScript Object</span></h3>

<p>Written directly into JavaScript, our JSON text looks a little different:

</p>

<pre class="brush: js">var movielisttext = "{"movielist": ["Friday the 13th", "Friday the 13th Part 2", "Friday the 13th Part III", "Friday the 13th: The Final Chapter", "Friday the 13th: A New Beginning"]}";

</pre>

<p>First, we are making a new variable to hold the text. That variable is named <tt>movielisttext</tt>. Since it&#8217;s a JavaScript string, the whole JSON text is surrounded by quotes. Next, any quotes inside the JSON have to be &#8220;escaped&#8221; with a backslash in front. Otherwise, JavaScript gets confused about which quotes we want for display and which quotes are part of the programming.



</p><p>Now that we have a JavaScript variable holding our JSON text, we need to convert it to a JSON object. I promised we&#8217;d be able to do this with one line of code. Here it is:

</p>

<pre class="brush: js">var jsonobj = eval("(" + movielisttext + ")");

</pre>

<p>The special JavaScript function we use to convert JSON text into an object is called <tt>eval</tt>, short for evaluate. It can take text that could be JavaScript and make it into actual JavaScript. To create an object from JSON text, all we have to do is pass the string to eval after surrounding the text with parentheses.

</p><p><br />

</p>

<a name="Accessing_the_JavaScript_Object"></a><h3> <span class="mw-headline">Accessing the JavaScript Object</span></h3>

<p>Finally, you can grab the array value from the object by using its attribute name, <tt>movielist</tt>:

</p>

<pre class="brush: js">var moviearray = jsonobj["movielist"];



</pre>

<p>You can then access the array like you would any JavaScript array. For example, here is the first Friday the 13th movie:

</p>

<pre class="brush: js">var firstmovie = moviearray[0];

</pre>

<p>Remember that arrays start counting at zero, not one. That&#8217;s why there&#8217;s a zero inside the brackets. The first movie is the zeroth element of the array.

</p><p>You can also access individual movies directly in the object, without pulling the array out. Here&#8217;s how you would grab the third movie from the object:

</p>

<pre class="brush: js">var thirdmovie = jsonobj["movielist"][2];

</pre>

<p><br />

</p>

<a name="Objects_with_More_Attributes:_A_Movie_Review"></a><h2> <span class="mw-headline">Objects with More Attributes: A Movie Review</span></h2>

<p>Arrays are only a small example of the data JSON can hold. What if we wanted to have a bunch of information held together in one object? All we have to do it give it more attributes.

</p><p>Let&#8217;s write some JSON to hold some information normally contained in a basic movie review. We want to know the name of the reviewer, how he or she rates the movie, and some prose describing the reviewer&#8217;s thoughts.



</p><p>Here&#8217;s how that might look in JSON:

</p>

<pre class="brush: js">{"reviewer": "Pam", "stars": 3, "text": "Pretty good, but could have used more Jason"}

</pre>

<p>This looks similar to our first example, but now we have several attributes, and they are separated by commas. Arrays also use commas to separate values. The difference here is that an object names each value with an attribute name.

</p><p><b>Note:</b> there are no quotes around the number of stars. When including numbers, JSON does not require quotes. In fact, if you want the number to let you add other numbers to it, for example, it cannot be in quotes.

</p><p><br />

</p>

<a name="Creating_and_Accessing_the_JavaScript_Object"></a><h3> <span class="mw-headline">Creating and Accessing the JavaScript Object</span></h3>

<p>Just like in the first example, creating a JavaScript object from JSON text is easy. First, declare the text:

</p>

<pre class="brush: js">var reviewtext = "{"reviewer": "Pam", "stars": 3, "text": "Pretty good, but could have used more Jason"}";

</pre>



<p>Then evaluate the text as an object:

</p>

<pre class="brush: js">var jsonobj = eval("(" + reviewtext + ")");

</pre>

<p>We can access the object attributes in the same way we retrieved the movie array in the first example. Here is how we get the reviewer&#8217;s name:

</p>

<pre class="brush: js">var reviewername = jsonobj["reviewer"];

</pre>

<p>JavaScript objects also have a quicker way to get at attributes. This method doesn&#8217;t require brackets and quotes:

</p>

<pre class="brush: js">var reviewername = jsonobj.reviewer;

var numberstars = jsonobj.stars;

var reviewerthoughts = jsonobj.text;

</pre>

<p>Just place a period after the object and then type in the name of the attribute. If you want to use the shorter method, it&#8217;s best to stick to attribute names that have no spaces.

</p><p><br />

</p>

<a name="Combination_Example:_One_Movie_and_its_Many_Reviews"></a><h2> <span class="mw-headline">Combination Example: One Movie and its Many Reviews</span></h2>



<p>So far, the JSON examples have been fairly simple. For this final example, we will combine the first two examples to show how objects can be nested inside of other objects or arrays.

</p><p>We want to use JSON text to hold basic information about a movie, then also contain a list of its reviews. Here&#8217;s how it might look:

</p>

<pre class="brush: js">{"title": "Friday the 13th", "year": 1980, "reviews": [{"reviewer": "Pam", "stars": 3, "text": "Pretty good, but could have used more Jason"}, {"reviewer": "Alice", "stars": 4, "text": "The end was good, but a little unsettling"}]}

</pre>

<p>The object that we create will have three attributes: title (a string), year (a number), and reviews (an array). This last attribute will contain a list of other values. In our very first example, our array contained strings. Here, the array contains other objects &#8212; review objects, like the one we created in the previous example.

</p><p><br />

</p>

<a name="Creating_and_Accessing_the_JavaScript_Object_2"></a><h3> <span class="mw-headline">Creating and Accessing the JavaScript Object</span></h3>

<p>To access the information in the JSON text, we need one line to declare the text and the other to evaluate it:

</p>

<pre class="brush: js">var moviereviewtext = "{"title": "Friday the 13th", "year": 1980, "reviews": [{"reviewer": "Pam", "stars": 3, "text": "Pretty good, but could have used more Jason"}, {"reviewer": "Alice", "stars": 4, "text": "The end was good, but a little unsettling"}]}";

var jsonobj = eval("(" + moviereviewtext + ")");

</pre>

<p>Now, to access the first review&#8217;s information, we need to dig to a second level of attributes:

</p>



<pre class="brush: js">var reviewername = jsonobj.reviews[0].reviewer;

var numberstars = jsonobj.reviews[0].stars;

var reviewerthoughts = jsonobj.reviews[0].text;

</pre>

<p>JSON can be nested many layers deep, making it a good choice for even complex data. Since the syntax is minimal (just a few brackets, quotes, and colons), sending data with JSON doesn&#8217;t require a lot of extra bandwidth.

</p><p><br />

</p>

<a name="Using_JSON_with_Your_Favorite_Language"></a><h2> <span class="mw-headline">Using JSON with Your Favorite Language</span></h2>

<p>There is at least one implementation of JSON in most popular web programming languages.

</p>

<ul><li> <a href="http://php.net/json" class="external text" title="http://php.net/json" rel="nofollow">PHP v5.2+</a>

</li><li> <a href="http://framework.zend.com/manual/en/zend.json.html" class="external text" title="http://framework.zend.com/manual/en/zend.json.html" rel="nofollow">PHP Zend framework</a>

</li><li> <a href="http://json.rubyforge.org/" class="external text" title="http://json.rubyforge.org/" rel="nofollow">Ruby</a>



</li><li> <a href="http://deron.meranda.us/python/comparing_json_modules/" class="external text" title="http://deron.meranda.us/python/comparing_json_modules/" rel="nofollow">Python has several options</a>

</li></ul>

<p>Java, Perl, .NET, Lisp, Erlang &#8212; you&#8217;ll find many JSON implementations listed at the bottom of <a href="http://json.org/" class="external text" title="http://json.org/" rel="nofollow">this page</a>.

</p><p><br />

</p>

<a name="APIs_that_Return_JSON"></a><h2> <span class="mw-headline">APIs that Return JSON</span></h2>

<p>Here are a sampling of APIs that use JSON or offer the option to get data returned in JSON format:

</p>

<ul><li> <a href="http://api.cnet.com/" class="external text" title="http://api.cnet.com/" rel="nofollow">CNet</a>



</li><li> <a href="http://api.flickr.com/" class="external text" title="http://api.flickr.com/" rel="nofollow">Flickr</a>

</li><li> <a href="http://code.google.com/apis/maps/documentation/" class="external text" title="http://code.google.com/apis/maps/documentation/" rel="nofollow">Google Geocoder</a>

</li><li> <a href="http://www.tumblr.com/api" class="external text" title="http://www.tumblr.com/api" rel="nofollow">Tumblr</a>

</li><li> <a href="http://groups.google.com/group/twitter-development-talk/web/api-documentation" class="external text" title="http://groups.google.com/group/twitter-development-talk/web/api-documentation" rel="nofollow">Twitter</a>

</li><li> <a href="http://developer.yahoo.com/answers/" class="external text" title="http://developer.yahoo.com/answers/" rel="nofollow">Yahoo Answers</a>

</li><li> <a href="http://developer.yahoo.com/search/local/V3/localSearch.html" class="external text" title="http://developer.yahoo.com/search/local/V3/localSearch.html" rel="nofollow">Yahoo Local Search</a>



</li><li> <a href="http://developer.yahoo.com/travel/" class="external text" title="http://developer.yahoo.com/travel/" rel="nofollow">Yahoo Travel</a>

</li><li> <a href="http://www.yelp.com/developers" class="external text" title="http://www.yelp.com/developers" rel="nofollow">Yelp</a>

</li></ul><div id='linker_widget' class='contextly-widget'></div>]]></content:encoded>
            <wfw:commentRss>http://www.webmonkey.com/2010/02/get_started_with_json/feed/</wfw:commentRss>
        <slash:comments>9</slash:comments>

        
    </item>
    </channel>
</rss>