{"id":170,"date":"2011-02-28T01:36:49","date_gmt":"2011-02-28T01:36:49","guid":{"rendered":"http:\/\/xphone.pt\/devnotes\/?p=170"},"modified":"2020-10-25T22:38:29","modified_gmt":"2020-10-25T22:38:29","slug":"json-vs-xml-part-1-data-size","status":"publish","type":"post","link":"http:\/\/xphone.pt\/devnotes\/2011\/02\/json-vs-xml-part-1-data-size\/","title":{"rendered":"JSON vs XML \u2013 Part 1: Data Size"},"content":{"rendered":"<p>In this test to compare XML vs JSON files data size, I transformed a sample of our XML data files to JSON, and I&#8217;ve obtained the following results:<\/p>\n<table border=\"1\">\n<tbody>\n<tr>\n<th style=\"text-align: center;\"><strong>File Name<\/strong><\/th>\n<th style=\"text-align: center;\"><strong>XML Size (bytes)<\/strong><\/th>\n<th style=\"text-align: center;\"><strong>JSON Size (bytes)<\/strong><\/th>\n<th style=\"text-align: center;\"><strong>Difference (bytes)<\/strong><\/th>\n<th style=\"text-align: center;\"><strong>Difference (%)<\/strong><\/th>\n<\/tr>\n<tr style=\"text-align: right;\">\n<td style=\"text-align: center;\">groups<\/td>\n<td style=\"text-align: right;\">6.218<\/td>\n<td style=\"text-align: right;\">3.379<\/td>\n<td style=\"text-align: right;\">&#8211; 2.839<\/td>\n<td style=\"text-align: right;\">-45.6 %<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">matches<\/td>\n<td style=\"text-align: right;\">14.541<\/td>\n<td style=\"text-align: right;\">8.823<\/td>\n<td style=\"text-align: right;\">-5.718<\/td>\n<td style=\"text-align: right;\">-39,3 %<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">scorers<\/td>\n<td style=\"text-align: right;\">1.250<\/td>\n<td style=\"text-align: right;\">652<\/td>\n<td style=\"text-align: right;\">-598<\/td>\n<td style=\"text-align: right;\">-47,8 %<\/td>\n<\/tr>\n<tr>\n<th><strong>TOTAL\/Average<\/strong><\/th>\n<th style=\"text-align: right;\"><strong>22.009<\/strong><\/th>\n<th style=\"text-align: right;\"><strong>12.854<\/strong><\/th>\n<th style=\"text-align: right;\"><strong>-9.155<\/strong><\/th>\n<th style=\"text-align: right;\"><strong>-41,6 %<\/strong><\/th>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>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.<\/p>\n<p>But wait! And if I reduce my tag\/field names&#8217; length to only 2 characters long?<\/p>\n<p>Here are the new results that I obtained after that change&#8230;<\/p>\n<table border=\"1\">\n<tbody>\n<tr>\n<th style=\"text-align: center;\"><strong>File Name<\/strong><\/th>\n<th style=\"text-align: center;\"><strong>XML Size (bytes)<\/strong><\/th>\n<th style=\"text-align: center;\"><strong>JSON Size (bytes)<\/strong><\/th>\n<th style=\"text-align: center;\"><strong>Difference (bytes)<\/strong><\/th>\n<th style=\"text-align: center;\"><strong>Difference (%)<\/strong><\/th>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">groups<\/td>\n<td style=\"text-align: right;\">3.444<\/td>\n<td style=\"text-align: right;\">2.934<\/td>\n<td style=\"text-align: right;\">-510<\/td>\n<td style=\"text-align: right;\">-14,8 %<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">matches<\/td>\n<td style=\"text-align: right;\">8.189<\/td>\n<td style=\"text-align: right;\">7.154<\/td>\n<td style=\"text-align: right;\">-1.035<\/td>\n<td style=\"text-align: right;\">-12,6 %<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center;\">scorers<\/td>\n<td style=\"text-align: right;\">756<\/td>\n<td style=\"text-align: right;\">556<\/td>\n<td style=\"text-align: right;\">-200<\/td>\n<td style=\"text-align: right;\">-26,5 %<\/td>\n<\/tr>\n<tr>\n<th style=\"text-align: center;\"><strong>TOTAL\/Average<\/strong><\/th>\n<th style=\"text-align: right;\"><strong>12.389<\/strong><\/th>\n<th style=\"text-align: right;\"><strong>10.644<\/strong><\/th>\n<th style=\"text-align: right;\"><strong>-1.745<\/strong><\/th>\n<th style=\"text-align: right;\"><strong>-14,1 %<\/strong><\/th>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>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.<\/p>\n<p>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&#8217;s true that can save me some bucks if I&#8217;m paying a non unlimited bandwidth hosting service. But maybe it isn&#8217;t sufficient to make me change my App, specially if it doesn&#8217;t will make my App to be implemented faster and run significantly better.<\/p>\n<p>By the way, until I publish the next post &#8220;<strong>JSON vs XML \u2013 Part 2: Parsing and Display Speed<\/strong>&#8220;, I recommend that you read an interesting article from Nicholas C. Zakas, which I found among many other articles about XML vs JSON: &#8220;<a title=\"Is JSON better than XML?\" href=\"http:\/\/www.nczonline.net\/blog\/2008\/01\/09\/is-json-better-than-xml\/\" target=\"_blank\" rel=\"noopener noreferrer\">Is JSON better than XML?<\/a>&#8220;.<\/p>\n<p>It compares several aspects of those two technologies in a succinct way.<\/p>\n<p><span style=\"text-decoration: underline;\">Note<\/span>: This is the first post of the &#8220;<a title=\"JSON vs XML \u2013 Data Size, Parsing and Display Speed\" href=\"http:\/\/xphone.pt\/devnotes\/2011\/02\/json-vs-xml-data-size-parsing-and-display-speed\/\" target=\"_self\" rel=\"noopener noreferrer\">JSON vs XML \u2013 Data Size, Parsing and Display Speed<\/a>&#8221; set.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this test to compare XML vs JSON files data size, I transformed a sample of our XML data files to JSON, and I&#8217;ve obtained the following results: File Name XML Size (bytes) JSON Size (bytes) Difference (bytes) Difference (%) groups 6.218 3.379 &#8211; 2.839 -45.6 % matches 14.541 8.823 -5.718 -39,3 % scorers 1.250 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[62,13,36,61,59,1,44,45],"tags":[15,14,39,60,49,43,70,3,4,46,47,48,71,40],"_links":{"self":[{"href":"http:\/\/xphone.pt\/devnotes\/wp-json\/wp\/v2\/posts\/170"}],"collection":[{"href":"http:\/\/xphone.pt\/devnotes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xphone.pt\/devnotes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xphone.pt\/devnotes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xphone.pt\/devnotes\/wp-json\/wp\/v2\/comments?post=170"}],"version-history":[{"count":15,"href":"http:\/\/xphone.pt\/devnotes\/wp-json\/wp\/v2\/posts\/170\/revisions"}],"predecessor-version":[{"id":305,"href":"http:\/\/xphone.pt\/devnotes\/wp-json\/wp\/v2\/posts\/170\/revisions\/305"}],"wp:attachment":[{"href":"http:\/\/xphone.pt\/devnotes\/wp-json\/wp\/v2\/media?parent=170"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xphone.pt\/devnotes\/wp-json\/wp\/v2\/categories?post=170"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xphone.pt\/devnotes\/wp-json\/wp\/v2\/tags?post=170"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}