Java Script Object Notation is a text based format for exchanging data. JSON is human readable format. JSON is language independent. It is light weight component. It doesn’t need any compilation process to execute it. It supports many languages. Ex: JAVA, C, C#, .net….. It has a standard database structure. It supports two type of structure in database.
1. Store values. Like an array in java.
2. Store key and corresponding values. Like map in java.
It is used as an alternate for xml.
Xml:–
XML stands for EXtensible Markup Language.
XML was designed to describe data.
XML is a software- and hardware-independent tool for carrying information.
Example—
In JSON:
| 1
2 3 4 5 6 7 8 9 10 |
{"Student": {
|
In XML:
| 1
2 3 4 5 6 |
<Student id="stuId" value="123">
|
Advantages of JSON
- Smaller message size
- More structural information in the document
- Can easily distinguish between the number 1 and the string “1” as numbers, strings (and Booleans) are represented differently in JSON.
- Can easily distinguish between single items and collections of size one (using JSON arrays).
- Easier to represent a null value
- Easily consumed by JavaScript. It supports all languages.
- Lightweight in comparison to XML
- Describing data as an object hierarchy, while XML has many other features as well.
Advantages of XML
- Namespaces allow for sharing of standard structures
- Better representation for inheritance
- Standard ways of expressing the structure of the document: XML schema, DTD, etc
- Parsing standards: DOM, SAX, StAX
- Standards for querying: XQuery and XPath
- Standards for transforming a document: XSLT.
Disadvantages of Json
- It is very difficult to understand by a human. Because of so many braces and commas used in that.
- JSON is not suitable for large data’s.
JSON does not have a < [CDATA []]> feature, so it is not suitable for handling multimedia formats. That is text, images etc
Note:CDATA means (Unparsed) Character Data.