TagJSON

JSON vs XML – Part 1: Data Size

In this test to compare XML vs JSON files data size, I transformed a sample of our XML data files to JSON, and I’ve obtained the following results:

File Name XML Size (bytes) JSON Size (bytes) Difference (bytes) Difference (%)
groups 6.218 3.379 – 2.839 -45.6 %
matches 14.541 8.823 -5.718 -39,3 %
scorers 1.250 652 -598 -47,8 %
TOTAL/Average 22.009 12.854 -9.155 -41,6 %

Well, after this first experiment it seems that I can save about 41,5 % on my data size if I change from XML to JSON files.

But wait! And if I reduce my tag/field names’ length to only 2 characters long?

Here are the new results that I obtained after that change…

File Name XML Size (bytes) JSON Size (bytes) Difference (bytes) Difference (%)
groups 3.444 2.934 -510 -14,8 %
matches 8.189 7.154 -1.035 -12,6 %
scorers 756 556 -200 -26,5 %
TOTAL/Average 12.389 10.644 -1.745 -14,1 %

Well, that size difference becomes reduced from near 41,5% to about 14%! It seems that with JSON I can save at least almost 2 KB per App update.

If I have 1.000 updates/day it gives less 2 MB of bandwidth which is perfectly negligible.With 1.000.000 updates/day it gives 2 GB/day, which becomes about 60 GB/month. It’s true that can save me some bucks if I’m paying a non unlimited bandwidth hosting service. But maybe it isn’t sufficient to make me change my App, specially if it doesn’t will make my App to be implemented faster and run significantly better.

By the way, until I publish the next post “JSON vs XML – Part 2: Parsing and Display Speed“, I recommend that you read an interesting article from Nicholas C. Zakas, which I found among many other articles about XML vs JSON: “Is JSON better than XML?“.

It compares several aspects of those two technologies in a succinct way.

Note: This is the first post of the “JSON vs XML – Data Size, Parsing and Display Speed” set.

JSON vs XML – Data Size, Parsing and Display Speed

In my previous post “App Interface and Data Update with UIWebViews, XML, XSLT and HTML“, I’ve written a little bit about how I have used XML to dynamically update and display our App’s data.

Following that, now that I’m preparing a new similar App, I’ve read lots of stuff about JSON and about JSON vs XML on the web, which is making me to consider the change of XML by JSON.

Many people argues that JSON is better than XML but that’s not clear and it seems that it depends a lot in what we need to do! Well, I know that’s not something new, it’s what happens most of the times when we’ve to choose some technology against other(s).

But I want to choose the “best” for my case, since I have plans to port this new App at least to Android OS and maybe to Windows Phone 7. And if that choice can reduce my total work in those platforms, it’ll be an important choice.

In general what I’ve seen is that XML is largely supported in all common browsers and in those mobile platforms. JSON is relatively new, however it’s becoming supported almost everywhere but mostly without native parsers.

That’s the case with iOS and WebKit (Safari’s engine). So I decided to do some previous experiments…

Since this article is growing a little more than I preview, I’ll publish the results of my tests in the following posts:

© 2024 myDevNotes

Theme by Anders NorénUp ↑