JSON vs XML. Technology comparison for beginners.

JSON and XML are used to receive and send data from the webserver. No matter what type of file you choose, you can always convert using Total XML Converter.

Both JSON and XML are used for receiving and sending data from the webserver.

What is XML?
XML (eXtensible Markup Language) is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. XML has been around for more than 20 years and is an integral part of any web application.

What is JSON?
JSON (JavaScript Object Notation) is a simple data exchange format based on the JavaScript programming language. Easy to read by people, easily processed and generated by programs.

JSON is popular now, and XML technologies are considered a relic of the past. Although still actively used.

JSON syntax rules

  • Data is specified in name / value pairs separated by a colon “firstName”: “Lev”
  • Data is separated by commas “firstName”: “Anna”, “lastName”: “Karenina”
  • Curly brackets hold objects {“firstName”: “Lev”, “lastName”: “Tolstoy”},
  • Square brackets contain arrays

Advantages of JSON

  • Less words more action. XML requires opening and closing tags, and JSON uses name / value pairs, clearly marked ” {“and”} “for objects, “[“and”] ” for arrays,”, “(comma) to separate the pair, and”: “(colon) to separate the name from the value.
  • Size matters. With the same amount of information, the JSON is almost always significantly smaller, which leads to faster transmission and processing.
  • Proximity to javascript. JSON is a subset of JavaScript, so the code for analyzing it and packaging it fits into JavaScript code quite naturally.

XML syntax

  • The entire XML document must have a root element.
  • All tags must be closed (or a self-closing tag).
  • All tags must be correctly nested.
  • Tag names are case-sensitive.
  • Tag names cannot contain spaces.
  • Attribute values must appear in quotation marks (“”).
  • Attributes can’t have attachments (unlike tags).
  • Space is saved.

Advantages of XML:

  • Metadata support. One of the biggest advantages of XML is that we can put metadata in tags in the form of attributes. In JSON, attributes will be added as other member fields in the data view that may NOT be desirable.
  • Browser render. Most browsers display XML in a readable and organized form. The XML tree structure in the browser allows users to collapse individual tree elements in a natural way. This function is especially useful when debugging.
  • Mixed content support. A good way to use XML is to transfer mixed content within the same data payload. This mixed content clearly differs by different tags.

No matter what type of file you choose, you can always convert using for example Total XML Converter.