<?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>CSSquirrel &#187; json</title>
	<atom:link href="http://www.cssquirrel.com/tag/json/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cssquirrel.com</link>
	<description>One nut's look at the world of web design</description>
	<lastBuildDate>Wed, 08 Sep 2010 17:13:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>jQuery, JSON and IE &#8211; Getting Incorrect Array Length</title>
		<link>http://www.cssquirrel.com/2008/10/14/jquery-json-and-ie-getting-incorrect-array-length/</link>
		<comments>http://www.cssquirrel.com/2008/10/14/jquery-json-and-ie-getting-incorrect-array-length/#comments</comments>
		<pubDate>Tue, 14 Oct 2008 20:24:58 +0000</pubDate>
		<dc:creator>Kyle Weems</dc:creator>
				<category><![CDATA[javascript]]></category>
		<category><![CDATA[Browsers]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[json]]></category>

		<guid isPermaLink="false">http://www.cssquirrel.com/?p=106</guid>
		<description><![CDATA[Has anyone had the following problem? When loading a JSON array (through something like $.getJSON), Internet Explorer will sometimes report the length of the array being one higher than other browsers, with the extra element in the array being blank.
I don&#8217;t know if this is a problem in other libraries, but I suspect it is. [...]]]></description>
			<content:encoded><![CDATA[<p>Has anyone had the following problem? When loading a <a title="Link to JSON.org" href="http://www.json.org/" target="_self">JSON</a> array (through something like <a title="Link to jQuery documentation on jQuery.getJSON" href="http://docs.jquery.com/Ajax/jQuery.getJSON#urldatacallback" target="_blank">$.getJSON</a>), Internet Explorer will sometimes report the length of the array being one higher than other browsers, with the extra element in the array being blank.</p>
<p>I don&#8217;t know if this is a problem in other libraries, but I suspect it is. But I do know that it&#8217;s happened to me when using jQuery&#8217;s Ajax functions.</p>
<p>Why is this occurring?</p>
<p>I was tormenting myself with this same question on a client project, and discovered that although a bit of browser quirkiness was involved, it was actually an error on my part.</p>
<p>I hate it when it&#8217;s me. <img src='http://www.cssquirrel.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><span id="more-106"></span></p>
<p>As it turns out, I had an extra trailing comma at the end of the last element in my array. For example, in the following array:</p>
<p><strong>{&#8220;gamesImDroolingFor&#8221;:[{"developer":"Blizzard","title:"Diablo III"},{"developer":"Square Enix","title":"Final Fantasy XIII"}<span style="color: #ff0000;">,</span>]}</strong></p>
<p>You&#8217;ll notice that there&#8217;s a comma after the last game&#8217;s bracket (which has been turned red for emphasis).</p>
<p>Firefox will ignore that comma, since clearly there&#8217;s no new object after it. Internet Explorer, the special child of the web, isn&#8217;t quite so bright, so it adds an extra, blank element to the array it creates.</p>
<p>Go IE.</p>
<p>The solution is easy, of course. Remove the unneeded comma.</p>
<p>I hope this helps prevent other developers from driving themselves batty trying to figure out what&#8217;s going wrong with their own arrays.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cssquirrel.com/2008/10/14/jquery-json-and-ie-getting-incorrect-array-length/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
