Before we compare JSON and XML, let's start with a brief history of the data format (more specifically, the ancestor of XML):
As early as 1970, IBM developed a markup language called Generalized Markup language, referred to as GML, which is primarily a set of macros defined for scripting languages.
In 1986, another markup language based on GML development, generalized Markup Language (SGML), was born and became the ISO standard, and then in 1998, SGML was redefined as XML.
On the other hand, JSON was the data format that Douglas Crockford began to promote in 2001, and in 2005-2006 became the mainstream data format, when Yahoo and Google began to use JSON in a wide format.
?
The definition of both
XML (extensible Markup Language) is a markup language used to encode documents, and both humans and machines can quickly understand the meaning of XML documents. One of its goals is to be widely used on the Internet, and XML is now widely used in various applications, Web services and Web sites.
JSON (JavaScript object Notation) is a lightweight data format that transmits data objects in a "name/value" format, and JSON is designed to replace XML, and now there are many programming languages that support JSON format.
From a grammatical point of view, the difference between the two is still very large
JSON is more readable than XML because of the reasonable use of code indentation and whitespace, and JSON does not take advantage of the fully tagged structure, so the code looks more compact and takes up less space.
Another advantage of JSON is that it can contain more structured information, such as: it is easier to express different data formats, such as numbers (one), strings ("11″") and null values, or even arrays.
On the other hand, XML is still widely used by developers, and as Big Brother in data format, XML has its own advantages, such as: XML has more documentation and development tools. Another advantage over JSON is that XML has an XML schema that describes XML structured information that can describe the XML document in detail and validate the data.
Select JSON or XML?
Finally, let's choose whether to select JSON or XML objectively. If you are going to learn JSON and its associated libraries, then you can continue to learn because JSON will be more popular and more widely used. In addition, if you are relatively conservative, you can persist in using XML, for so many years old markup language, proved that the existence of XML has its value, and it will not be replaced in the future.
JSON and XML