ARCHIVE / What are the advantages of using JSON?

Because JSON was designed for the purpose of serializing and unserializing data being sent to and from JavaScript applications, the advantages of using JSON relate to the advantages of JSON over other means of serialization.  The most well-known means of serializing data for transmission to and from applications at present is XML.  Yet, XML is a rather cumbersome means of serialization.  First, the sender must encode the data to be serialized based on a document type definition that the recipient understands.  Doing so creates a great deal of extra padding around the actual data no matter which DTD is used.  So, the size of XML documents is often fairly large in comparison with the actual set of values they contain.  Second, the recipient must receive the stream of XML and decode the data in order to then put that data into memory.  In comparison, the serialization of data using JSON by the sender is relatively quick and compact because the structure of JSON reflects the structure of standard programming data types and the encoding mechanism adds only the minimum number of characters required to indicate the structure and value of the data.  Once the recipient receives the JSON serialized data, then, the only processing needing to be done is to evaluate the text of the string using either JavaScript's built-in eval function or a compatible function in another language.  The other standard comparison is YAML, which is able to serialize complex data sets without relying upon a DTD and needs a simpler parser to both read and write than XML.  However, even the simplified YAML parsers generally require more time and generate larger serialized data streams than JSON.

last updated 2007.09.27



Terms of Use · Privacy Policy ©2020