Skip to main content

XML and JSON maybe two of the most helpful applications which utilize APIs to drive their respective front ends, performance becomes their emerging concern. But what not so many web designers know is that XML is more popular as a method for exchanging data, but now with the existence of JSON, world acknowledge a new standard. But this doesn’t mean that one of them is better than the other. If you would like to be an API designer, it’s important to understand the foundations and differences of JSON and XML.

XML: ‘Data Stuffed’

XML actually has the same function with HTML, however HTML is responsible for displaying data in a human-readable format (in a Web browser, for example), while XML is responsible for representing the structure of that data before it is transported from one system to another. In the other hand, XML is better defined, widely supported and clearly structured. In fact, these attributes terribly needed in order to make a fundamental part of the web when SOAP (simple object Access Protocol), the precursor to RESTful web Services, was the preferred way for one system to request data from another over the web.

XML invariably structures with responses. The SOAP requests which are transported for disassembly were actually hand-crafted and stuffed with data. Besides, there is no guarantee that the stakeholders on the receiving side of the transaction were parsing the document and displaying it neatly, HTML front-end application. In fact, mostly people read that kind of document through Microsoft Notepad.

All of this proves that XML can hold any data type even in an easier to read format. For example:

<?xml version=”1.0″ encoding=”ISO-8859-1″?>
<document>
 <patient>
 <firstname>Test</firstname>
 <lastname>Patient</lastname>
 </patient>
 <allergies>
 <allergy>
 <name>Wheat</name>
 <severity>3</severity>
 </allergy>
 </allergies>
 </document>

 

JSON: Efficiency is priority

Even though XML has been proved that it has worked well in many different situations, but in most and certain cases, JavaScript Object Notation (JSON) is more popular as data marshaling. The reasons are many, but they include the way in which modern browsers offer better data transferring, this is because JSON function structure is shorter that causes any efficiency in its process and save bandwidth. This is where JSON’s popularity shines: It is extremely fast at serialization and deserialization. For example, through JSON, a complex C# domain object can be serialized into a JSON string and transported in a single line of code, such as below:

{“books” : [
{ “title”: “My First Book”, “Author” : “Fake Author” },
{ “title”: “Test book” , “Author” : “Real Author” }
] }

 Conclusion

As it is stated in the beginning that there is no good or bad among two of them, it is simply a matter of different advantages between the two. Even though, In terms of efficiency, JSON is above XML, but XML can be used in creating interfaces, such as Java programming which JSON cannot, for example, you can take a look at the most popular usage for XML today is Android programming which is fully in XML. XML also can be applied as a storing media which is widely used as short data storage.