JSON is “faster” than XML
Using JSON data in lieu of XML will make your Metro apps 46% faster!
Rendered JSON data is smaller than XML. Which means JSON requires less time to travel.
“But, I don’t have JSON data. I have XML data.”
Don’t worry – I’ll get to that.
Using Fiddler, we will measure the resulting file size and network transfer time of an RSS feed in XML and JSON format. For our sample data, we’ll use the wildly famous, unbelievably spectacular and world renowned Internet show, “The Metro Developer Show” </shameless plug>
Below, a screenshot from Fiddler depicting the network transfer times of our RSS feed in XML and JSON format. 62 seconds vs. 33 seconds!
|XML – 62 seconds|
|JSON – 33 seconds|
Of course, the above screen shots uses a theoretical network speed of 6KB/sec. This would never rarely happen. But it could. And why not code for the lowest common dominator!?
Let’s take a look at file sizes. Below, we see the resulting file sizes of the RSS feed in XML and JSON format. What a difference!
|XML – 376,744 bytes|
|JSON – 201,529 bytes|
Less data. Less time. Everyone wins!
How To Parse XML as JSON with 2 Lines of Code
All we need is 2 lines of code. One line specifies the URL of our XML feed. The second line encodes our URL and concatenates it with the base URL for the Google API. Then we make our normal XHR request. Instant JSON data endpoint! Free, fast and highly available!