XML and JSON are both designed to form a simple and standartized way of describing different kinds of hierarchical data structures and to facilitate their transportation and consumption in a standartized way. Nonetheless, there are few substantial differences that deserve attention.
JSON :
XML :
Clearly XML is somehow easier to understand for a human. That’s why it’s commonly used for configuration files (although lambdas and fluent APIs are recently emerging as a way of configuration). JSON, on ther other hand, is harder to read, but only from a human perspective.
Aside from that, XML is also a markup language (as the name suggests) and is therefore suitable for document description – the hierarchical elements can also have attributes, which is not present in JSON. On ther other hand, JSON has a very concise syntax for defining lists of elements, which makes it preferrable for text format object serialization.
XML is also the usual choice of base when it comes to Domain Specific Languages.
The major differences
Take a look at the following example:JSON :
XML :
Clearly XML is somehow easier to understand for a human. That’s why it’s commonly used for configuration files (although lambdas and fluent APIs are recently emerging as a way of configuration). JSON, on ther other hand, is harder to read, but only from a human perspective.
Aside from that, XML is also a markup language (as the name suggests) and is therefore suitable for document description – the hierarchical elements can also have attributes, which is not present in JSON. On ther other hand, JSON has a very concise syntax for defining lists of elements, which makes it preferrable for text format object serialization.
XML is also the usual choice of base when it comes to Domain Specific Languages.
No comments:
Post a Comment