Home Login Create account Contact Help
Close

Login to your account

Other Options

Tags: Json Web Xml

JSON or XML for structured data serialization

There are many cases where it is useful to serialize data structures to text, such as persistence in the filesystem or transmission across the network. One of the most popular uses is to use ECMAScript to update a web page without reloading, using an asynchronous channel to a web server (AJAX). Other popular uses are for configuration files, data caches, simple networking protocols, and web-based data APIs.

The two most popular serialization formats are XML and JSON. Which do you think is preferable?



Log in to post an argument Subscribe to feed
Rank order
JSON
JSON is a better serialization format.
John Millikin argues...
Sat, 29 Mar 2008 by jmillikin
Average 0.0 ( 0 votes )
JSON has semantics for data types beyond text, such as numbers, lists, and associative maps. This allows data structures without complex objects to be serialized with very little fuss. Even moderately complex objects may be serialized if they can be reduced to basic data types.
John Millikin argues...
Sat, 29 Mar 2008 by jmillikin
Average 0.0 ( 0 votes )
One way to do it. In XML, it is a choice of the programmer on whether to use attributes or child elements to store associated data. Each has its own advantages and disadvantages (generality v. simplicity). The child element method provides both associative mapping and list behavior.

JSON separates these into different syntaxes, so that mappings use {} and lists use .
John Millikin argues...
Sat, 29 Mar 2008 by jmillikin
Average 0.0 ( 0 votes )
After parsing, a JSON data set can be accessed directly within a browser through standard syntax. XML requires use of the DOM for traversal, which is complex enough to have tutorials [w3schools.com].
XML
XML is a better serialization format.
John Millikin argues...
Sat, 29 Mar 2008 by jmillikin
Average 0.0 ( 0 votes )
XML has superior library support, and there are generally multiple performant and compliant XML (de)serializers for any given language.
John Millikin argues...
Sat, 29 Mar 2008 by jmillikin
Average 0.0 ( 0 votes )
XML has standard facilities for metadata such as the text encoding and language, and can be serialized in any encoding. JSON relies on encoding autodetection, and therefore may only be serialized to one of the UTF-* encodings.
John Millikin argues...
Sat, 29 Mar 2008 by jmillikin
Average 0.0 ( 0 votes )
JSON does not support any comment syntax. XML has <!-- ... -->.