/  Technology   /  Difference Between JSON and XML

Difference Between JSON and XML

Difference Between JSON and XML

 

Data formats differ between computer systems and databases. It is possible for these data to be incompatible with one another. Two common formats for transferring data between web systems are JSON and XML. JSON (JavaScript Object Notation) is a meta-language, while XML (eXtensible Markup Language) is a markup language.

What is JSON?

The JavaScript Object Notation allows data to be exchanged between different platforms. The language is easy to read and write. In most cases, JSON is used with Asynchronous JavaScript (AJAX) and to develop RESTful web services. It can also be used with many languages, such as Java, C, C++, and Python. Number, Boolean, String, Array, Object, Null are some of the data types of JSON.  In JSON syntax, data is separated by commas and key value pairs are used.

Example : 

{
“id” : “L001”,
“name” : “Ganesh”
}

What is XML?

XML stands for “eXtensible Markup Language”. Tag-based syntax is very similar to HTML, but it is not a replacement for HTML. Web pages can be structured using HTML. The more general purpose format is XML. Programmers can create tags on their own with XML, which is its main advantage. Many web technologies are based on XML. Among them are XHTML, AJAX, and Web Services. HTML is formatted as XML syntax in XHTML. Web services use AJAX to develop APIs. XPath, XSLT, and XQuery are some of the technologies related to XML.

Both client-side and server-side reading of XML is possible. It is available in a variety of languages. A programmer can use XML with C#, Visual Basic, Python, or  JavaScript. XML is used on a wide range of platforms, including Java, .NET, iOS, and Android. One of the main advantages of XML is that it can serve as a bridge between two different systems. An older computer system may be present in a bank, for example. In order to connect it to a new system and to exchange data, XML can be used. Despite the fact that these two systems are completely different, it is possible to exchange data between them.

Example : 

<student>
<id>L01</id>
<name> Ganesh</name>
</student>

Large datasets are not suitable for XML. If this is the case, a database should be used. XML may become difficult to read when the data becomes complex.

The following is an example of a JSON array.

{ “students”: [
{ “id” : “L001”, “name” : “Ganesh”},
{ “id” :”L002″ ,”name” : “Venkat”}
] }

An example of an XML document.

<students>
<student>
<id> L001 </id> <name> Ganesh</name>
<id> L002 </id> <name> Venkat</name>
</student>
</students>

What is the Difference Between JSON and XML

JSONXML
DefinitionThe JavaScript Object Notation (JSON) is an open standard for exchanging text-based data.Data exchange in XML (eXtensible markup language) is independent of software and hardware.
TypeThe JSON language is a meta-language.A markup language is XML.
ComplexityThe JSON format is simple and easy to understand.The XML format is more complex.
OrientationThe JSON format is data-oriented.Documents are the focus of XML.
ArraysArrays are supported by JSON.Arrays are not supported by XML.
File ExtensionThe extension of a JSON file is .json.The extension of an XML file is .xml.

 

Leave a comment