So why would I use JSON rather than XML ?
Other than in cases such as web services that demand the use of JSON.
Notes
JSON (JavaScript Object Notation) is fast becoming an essential technology in modern IBM i shops. From web services to browser interfaces and data exchange—it has seen a remarkable growth in usage over the last few years. In recent times IBM have even added direct JSON support to DB2.
JSON began basically as a replacement for XML in Ajax calls. That’s somewhat ironic when you consider that the "x" in Ajax actually stands for XML—“Asynchronous Javascript and XML" ... But then the X in XML stands for eXtensible so a little irony is perhaps appropriate.
JSON is "Better" Because ...
- It is far more compact
- Only 60 - 70% of the size of comparable XML
- Shorter transmission overhead
- Its syntax is simpler
- No namespaces
- Simpler approach to escaping special characters
- Only UTF-8 is supported
- XML has to worry about multiple encodings
- Faster to decode
- For example arrays have a specific syntax
- Whereas arrays in XML are just repeats of an element
JSON also only uses UTF-8 encoding and so the multiple data encodings supported by XML do not have to be dealt with.
With this three-fold advantage (compactness, ease of parsing, everything in UTF-8) it was hardly surprising that JSON rapidly replaced XML in most Ajax calls. From there it has gone on to become the vehicle of choice for web service requests and responses, and is making significant strides in the area of data interchange.
No comments:
Post a Comment