<?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>João Prado Maia's Weblog &#187; JavaScript</title>
	<atom:link href="http://pessoal.org/blog/category/javascript/feed/" rel="self" type="application/rss+xml" />
	<link>http://pessoal.org/blog</link>
	<description></description>
	<lastBuildDate>Sat, 02 Oct 2010 01:04:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>iPhone SDK: Parsing semi-complex JSON objects</title>
		<link>http://pessoal.org/blog/2009/01/15/iphone-sdk-parsing-complex-json-objects/</link>
		<comments>http://pessoal.org/blog/2009/01/15/iphone-sdk-parsing-complex-json-objects/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 04:01:18 +0000</pubDate>
		<dc:creator>jpm</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Objective-C]]></category>
		<category><![CDATA[iPhone SDK]]></category>

		<guid isPermaLink="false">http://pessoal.org/blog/?p=140</guid>
		<description><![CDATA[Since this seems to be quite common for newcomers to Objective-C / iPhone development, here&#8217;s another example on how to parse a semi-complex JSON object. This was asked as a comment on a previous post, but I think that deserves its own space. The JSON object looks something like the following: {&#34;start&#34;:0, &#34;stat&#34;:&#34;ok&#34;, &#34;locations&#34;:[{&#34;name&#34;:&#34;Pensacola, FL&#34;, [...]]]></description>
			<content:encoded><![CDATA[<p>Since this seems to be quite common for newcomers to Objective-C / iPhone development, here&#8217;s another example on how to parse a semi-complex JSON object. This was asked as a comment on a previous post, but I think that deserves its own space.</p>
<p>The JSON object looks something like the following:</p>

<div class="wp_syntax"><div class="code"><pre class="json" style="font-family:monospace;">{&quot;start&quot;:0,
 &quot;stat&quot;:&quot;ok&quot;,
 &quot;locations&quot;:[{&quot;name&quot;:&quot;Pensacola, FL&quot;,
               &quot;place_id&quot;:&quot;qQ7Vig2bBZsZCy82&quot;,
               &quot;woeid&quot;:2470377}],
 &quot;count&quot;:3,
 &quot;total&quot;:3,
 &quot;query&quot;:&quot;address=Pensacola&quot;}</pre></div></div>

<p>So you can quickly see that it&#8217;s an object, with a &#8220;locations&#8221; entry that contains an array of objects. This looks like an object that represents the search results for a location from some web service.</p>
<p>I will parse that complex object by creating separate variables to hold specific parts of the object, but there are simpler ways to do this. In this example, I want to get the value for the &#8220;name&#8221; key in the first item of the &#8220;locations&#8221; array.</p>

<div class="wp_syntax"><div class="code"><pre class="objc" style="font-family:monospace;"><span style="color: #11740a; font-style: italic;">// jsonString contains the actual JSON output from your web service</span>
SBJSON <span style="color: #002200;">*</span>json <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span><span style="color: #002200;">&#91;</span>SBJSON alloc<span style="color: #002200;">&#93;</span> init<span style="color: #002200;">&#93;</span>;
<span style="color: #400080;">NSError</span> <span style="color: #002200;">*</span>error <span style="color: #002200;">=</span> <span style="color: #a61390;">nil</span>;
<span style="color: #11740a; font-style: italic;">// object containing full results</span>
<span style="color: #400080;">NSDictionary</span> <span style="color: #002200;">*</span>results <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>json objectWithString<span style="color: #002200;">:</span>jsonString error<span style="color: #002200;">:&amp;</span>error<span style="color: #002200;">&#93;</span>;
<span style="color: #11740a; font-style: italic;">// array just for the &quot;location&quot; results</span>
<span style="color: #400080;">NSArray</span> <span style="color: #002200;">*</span>locations <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>results objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;locations&quot;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #11740a; font-style: italic;">// first location in your array</span>
<span style="color: #400080;">NSDictionary</span> <span style="color: #002200;">*</span>firstLocation <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>locations objectAtIndex<span style="color: #002200;">:</span><span style="color: #2400d9;">0</span><span style="color: #002200;">&#93;</span>;
<span style="color: #11740a; font-style: italic;">// finally, the name key</span>
<span style="color: #400080;">NSString</span> <span style="color: #002200;">*</span>name <span style="color: #002200;">=</span> <span style="color: #002200;">&#91;</span>firstLocation objectForKey<span style="color: #002200;">:</span><span style="color: #bf1d1a;">@</span><span style="color: #bf1d1a;">&quot;name&quot;</span><span style="color: #002200;">&#93;</span>;
<span style="color: #002200;">&#91;</span>json release<span style="color: #002200;">&#93;</span>;</pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://pessoal.org/blog/2009/01/15/iphone-sdk-parsing-complex-json-objects/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>JavaScript event compatibility tests</title>
		<link>http://pessoal.org/blog/2008/04/30/javascript-event-compatibility-tests/</link>
		<comments>http://pessoal.org/blog/2008/04/30/javascript-event-compatibility-tests/#comments</comments>
		<pubDate>Wed, 30 Apr 2008 15:58:13 +0000</pubDate>
		<dc:creator>jpm</dc:creator>
				<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://pessoal.org/blog/?p=94</guid>
		<description><![CDATA[Peter-Paul Koch expanded his set of event compatibility tests (not updated since 2005) to cover some of the newer versions of browsers available today. The results are very useful, and include dozens of bugs throughout the browsers, and lots of tips on things to avoid. Recommended.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.quirksmode.org/blog/archives/2008/04/event_compatibi.html">Peter-Paul Koch expanded his set of event compatibility tests</a> (not updated since 2005) to cover some of the newer versions of browsers available today. <a href="http://www.quirksmode.org/dom/events/index.html">The results</a> are very useful, and include dozens of bugs throughout the browsers, and lots of tips on things to avoid. Recommended.</p>
]]></content:encoded>
			<wfw:commentRss>http://pessoal.org/blog/2008/04/30/javascript-event-compatibility-tests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prototip: tooltips for Prototype</title>
		<link>http://pessoal.org/blog/2008/04/21/prototip-tooltips-for-prototype/</link>
		<comments>http://pessoal.org/blog/2008/04/21/prototip-tooltips-for-prototype/#comments</comments>
		<pubDate>Mon, 21 Apr 2008 22:28:30 +0000</pubDate>
		<dc:creator>jpm</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Prototype]]></category>

		<guid isPermaLink="false">http://pessoal.org/blog/?p=75</guid>
		<description><![CDATA[Prototip is a cool little project that works well with sites that already use Prototype. Lots of easy ways to implement tooltips in your pages, even while using AJAX.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.nickstakenburg.com/projects/prototip/">Prototip</a> is a cool little project that works well with sites that already use Prototype. Lots of easy ways to implement tooltips in your pages, even while using AJAX.</p>
]]></content:encoded>
			<wfw:commentRss>http://pessoal.org/blog/2008/04/21/prototip-tooltips-for-prototype/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SWFUpload: upload files via Flash</title>
		<link>http://pessoal.org/blog/2008/03/27/swfupload-upload-files-via-flash/</link>
		<comments>http://pessoal.org/blog/2008/03/27/swfupload-upload-files-via-flash/#comments</comments>
		<pubDate>Thu, 27 Mar 2008 15:33:11 +0000</pubDate>
		<dc:creator>jpm</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://pessoal.org/blog/2008/03/27/swfupload-upload-files-via-flash/</guid>
		<description><![CDATA[This is a really cool project that I found out through Jonathan Boutelle&#8217;s presentation at SXSW&#8217;08 called AJAX and Flash mistakes. That&#8217;s basically what they use on Slideshare to upload documents to their system. It seems pretty useful, and I&#8217;m already thinking about using it in a few projects in the future. You can find [...]]]></description>
			<content:encoded><![CDATA[<p>This is a really cool project that I found out through Jonathan Boutelle&#8217;s presentation at SXSW&#8217;08 called <a href="http://www.jonathanboutelle.com/mt/archives/2008/03/ajax_and_flash_1.html">AJAX and Flash mistakes</a>. That&#8217;s basically what they use on Slideshare to upload documents to their system.</p>
<p>It seems pretty useful, and I&#8217;m already thinking about using it in a few projects in the future. You can find more details about it on the <a href="http://swfupload.org">homepage</a>.</p>
<p>My only concern is that in some scenarios you may want to avoid a hard dependency on Flash, but for consumer sites it seems like a safe choice.</p>
]]></content:encoded>
			<wfw:commentRss>http://pessoal.org/blog/2008/03/27/swfupload-upload-files-via-flash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Drip: memory leak detector for IE</title>
		<link>http://pessoal.org/blog/2008/03/18/drip-memory-leak-detector-for-ie/</link>
		<comments>http://pessoal.org/blog/2008/03/18/drip-memory-leak-detector-for-ie/#comments</comments>
		<pubDate>Tue, 18 Mar 2008 15:35:46 +0000</pubDate>
		<dc:creator>jpm</dc:creator>
				<category><![CDATA[IE hacks]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Performance Tuning]]></category>

		<guid isPermaLink="false">http://pessoal.org/blog/2008/03/18/drip-memory-leak-detector-for-ie/</guid>
		<description><![CDATA[I found out about Drip through John Resig&#8217;s Secrets of JavaScript Libraries panel at SXSW this year. Unfortunately I couldn&#8217;t attend his panel, but the presentation document seems like a good read. Anyway, Drip is a memory leak detector application for Internet Explorer. It basically runs IE within the application itself, and analyzes the memory [...]]]></description>
			<content:encoded><![CDATA[<p>I found out about <a href="http://www.outofhanwell.com/ieleak/index.php?title=Main_Page">Drip</a> through John Resig&#8217;s <a href="http://www.slideshare.net/jeresig/secrets-of-javascript-libraries">Secrets of JavaScript Libraries</a> panel at SXSW this year. Unfortunately I couldn&#8217;t attend his panel, but the presentation document seems like a good read.</p>
<p>Anyway, Drip is a memory leak detector application for Internet Explorer. It basically runs IE within the application itself, and analyzes the memory usage for any leaks. Seems really really useful, and just by playing with it for a few minutes I already found a couple of pieces of code to fix.</p>
]]></content:encoded>
			<wfw:commentRss>http://pessoal.org/blog/2008/03/18/drip-memory-leak-detector-for-ie/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

