Java Reference
In-Depth Information
get the best possible performance out of whichever representation is chosen, rather than to
drive a choice that might not be optimal for a particular environment.
Data Size
Basic Web Container Performance showed the effect of the size of data on overall perform-
ance. In a distributed network environment, that size is always important. In that regard,
JSON is widely considered to be smaller than XML, though that difference is typically small.
In the tests for this section, I used the XML and JSON returned from requesting the 20 most
popular items from eBay. The XML in that example is 23,031 bytes, while the JSON is smal-
ler at only 16,078 bytes. The JSON data has no whitespace at all, making it difficult for a hu-
man to read, which makes sense—human readability isn't the goal. But oddly, the XML data
is well structured, with lots of whitespace; it could be trimmed to 20,556 bytes. Still, that's a
25% difference, which occurs mostly because of the XML closing tags. In general, those
closing tags will always make the XML output larger. Interestingly, there are a number of
websites that automatically convert XML to JSON. These tend to take a naive approach; the
JSON output will usually be larger than the XML data, mostly because human-readable
JSON output has lots of whitespace, and a lot of unneeded structure.
Search WWH ::




Custom Search