JSON vs XML
Parag Paratkar
Product - Payment Solutions | API , Checkout | Problem Solver | Ex-Banker | Studied at IIT Bombay
You exchange information daily with people via social media using text, photos, videos. Text, photos, and videos are data formats using which you convey thoughts.
A well-designed data format makes the information easiest to understand.
The same principle applies when two systems connect and share data using APIs. One system has to format the data in a way that other system can understand. The most common formats used in API world are JSON and XML.
JSON (JavaScript Object Notification)
JSON is the most popular data format when data is exchanged using APIs. Below are features that make JSON favorite among developers.
- JSON is self-explanatory and easy to understand
- JSON is lightweight
- JSON is language independent
JSON Syntax Rules:
- JSON data is in key/value pairs
- JSON data is separated by commas
- Curly braces hold JSON objects
- Square brackets hold JSON arrays
XML (eXtensible Markup Language)
XML has been around since 1996. With age, it has become more mature and powerful data format. Like JSON, XML also uses syntax to structure the data.
XML Syntax Rules:
- XML starts with root node, called a parent node
- Inside parent node, there are child nodes
Similarities between JSON and XML
- Both JSON and XML are "self-describing" (human-readable)
- Both JSON and XML are hierarchical (values within values)
Dissimilarities between JSON and XML
Thanks for reading