14 Difference Between JSON And XML

SHARE

What Is JSON(JavaScript Object Notation)?

JSON is an open standard file format and data interchange format, that uses human-readable text to store and transit data objects. It is used primarily to transmit data between a server and web application, as an alternative to XML. JSON defines seven value types: string, number, object, array, true, false and null.

JSON is built on two structures:

  • A collection of name/value pairs. In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list or associative array.
  • An ordered list of values. In most languages, this is realized as an array, vector, list or sequence.

JSON is often used as a common format to serialize and deserialize data in applications that communicate with each other over the Internet. These applications are created using different programming languages and run in very different environments. JSON is suited to this scenario because it is an open standard, it is easy to read and write and it is more compact than other representations.

What You Need To Know About JSON

  1. JavaScript Object Notation (JSON) is one type of text-based format or standard for interchanging data i.e Human readable.
  2. JSON is developed by Douglas Crockford.
  3. JSON is extended from JavaScript language from where it puts the feature to represent the data in a way of representing objects.
  4. JSON does not provide any support for name-spaces but supports Arrays.
  5. JSON is data oriented and can be mapped more easily.
  6. JSON has support of native objects.
  7. JSON does not support comments.
  8. JSON syntax is lighter than XML as JSON has serialized format of data having less redundancy. JSON does not contain start and end tags.
  9. JSON supports data-type including integer and strings, JSON also support array.  
  10. JSON files are easy to read as compared to XML.
  11. JSON is less secured.
  12. JSON supports only UTF-8 encoding.
  13. It is supported by many Ajax toolkit.
  14. You cannot change JSON data to another format.

What Is XML (Extensible Markup Language)?

Extensible Markup Language (XML) is a markup language that defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. The basic building block of an XML document is an element, defined by tags. An element has a beginning and an ending tag. All elements in an XML document are contained in an outermost element known as the root element. XML can also support nested elements or elements within elements. This ability allows XML to support hierarchical structures. Element names describe the content of the element, and the structure describes the relationship between the elements. XML also supports the ability to define attributes for elements and describe characteristics of the elements in the beginning tag of an element.

XML data is known as self-describing or self-defining, meaning that the structure of the data is embedded with the data, thus when the data arrives there is no need to pre-build the structure to store the data; it is dynamically understood within the XML. The XML format can be used by any individual or group of individuals or companies that want to share information in a consistent way. XML is actually a simpler and easier-to-use subset of the SGML (Standard Generalized Markup Language), which is the standard to create a document structure.

What You Need To Know About XML

  1. The Extensible Markup Language (XML)is a Markup Language having format that contains set of rules for the encoding the documents which is readable for both human and Machine.
  2. XML is developed by W3C (World Wide Web Consortium).
  3. XML is extended from SGML (Standard Generalized Markup Language) and uses tag structure to represent data items.  
  4. XML support name-spaces but does not support Arrays.
  5. XML is document oriented and needs more effort for mapping.
  6. XML can get support of objects through mixed use of attributes and elements.
  7. XML supports comments.
  8. XML is not so lighter as JSON having start and ends tags and it takes more character than JSON to represent same data.
  9. XML does not provide any data type so needs to be parsed into particular data-type. XML has no direct support for array.
  10. XML documents are relatively more difficult to read and interpret.
  11. XML is more secure than JSON.
  12. XML supports UTF-8 encoding and other various types of encoding.
  13. It not fully supported by Ajax toolkit.
  14. In XML, using XSLT you can change XML data into another format like comma-delimited, plain text, JSON etc.

Difference Between JSON And XML In Tabular Form

BASIS OF COMPARISON JSON XML
Description JavaScript Object Notation (JSON) is one type of text-based format or standard for interchanging data i.e Human readable.   The Extensible Markup Language (XML)is a Markup Language having format that contains set of rules for the encoding the documents which is readable for both human and Machine.  
Development JSON is developed by Douglas Crockford.   XML is developed by W3C (World Wide Web Consortium).  
Extension JSON is extended from JavaScript language from where it puts the feature to represent the data in a way of representing objects.   XML is extended from SGML (Standard Generalized Markup Language) and uses tag structure to represent data items.   
Support For Name-Spaces But Supports Arrays JSON does not provide any support for name-spaces but supports Arrays.   XML support name-spaces but does not support Arrays.  
Nature JSON is data oriented and can be mapped more easily.   XML is document oriented and needs more effort for mapping.  
Support of Native Objects JSON has support of native objects.   XML can get support of objects through mixed use of attributes and elements.  
Support For Comments JSON does not support comments.   XML supports comments.  
Start & End Tags JSON syntax is lighter than XML as JSON has serialized format of data having less redundancy. JSON does not contain start and end tags.   XML is not so lighter as JSON having start and ends tags and it takes more character than JSON to represent same data.  
Data-Type JSON supports data-type including integer and strings, JSON also support array.     XML does not provide any data type so needs to be parsed into particular data-type. XML has no direct support for array.  
Document Reading & Interpretation JSON files are easy to read as compared to XML.   XML documents are relatively more difficult to read and interpret.  
Security JSON is less secured.   XML is more secure than JSON.  
UTF-8 Encoding JSON supports only UTF-8 encoding.   XML supports UTF-8 encoding and other various types of encoding.  
Ajax Toolkit It is supported by many Ajax toolkit.   It not fully supported by Ajax toolkit.  
Change Of Data You cannot change JSON data to another format.   In XML, using XSLT you can change XML data into another format like comma-delimited, plain text, JSON etc.