What is JSON
- JSON: JavaScript Object Notation.
- JSON is a lightweight text-based open standard designed for human-readable data interchange.
- JSON is easy for humans to read and write. It is easy for machines to parse and generate.
- JSON data format is ideally suited for consumption by a JavaScript program. (In fact, JSON is JavaScript!)
JSON VS XML
Source : http://www.json.org/xml.html
Simple
XML is simpler than SGML, but JSON is much simpler than XML. JSON has a much smaller grammar and maps more directly onto the data structures used in modern programming languages.
Extensible
JSON is not extensible because it does not need to be. JSON is not a document markup language, so it is not necessary to define new tags or attributes to represent data in it.
Interoperabity
JSON has the same interoperability potential as XML.
Openness
JSON is at least as open as XML, perhaps more so because it is not in the center of corporate/political standardization struggles.
XML is human readable
JSON is much easier for human to read than XML. It is easier to write, too. It is also easier for machines to read and write.
XML can be used as an exchange format to enable users to move their data between
similar applications
The same is true for JSON.
XML provides a structure to data so that it is richer in information
The same is true for JSON.
XML is easily processed because the structure of the data is simple and standard
JSON is processed more easily because its structure is simpler.
There is a wide range of reusable software available to programmers to handle
XML so they don't have to re-invent code
JSON, being a simpler notation, needs much less specialized software. In the languages JavaScript and Python, the JSON notation is built into the programming language; no additional software is needed at all. In other languages, only a small amount of JSON-specific code is necessary. For example, a package of three simple classes that makes JSON available to Java is available for free from JSON.org.
XML separates the presentation of data from the structure of that data.
XML requires translating the structure of the data into a document structure. This mapping can be complicated. JSON structures are based on arrays and records. That is what data is made of. XML structures are based on elements (which can be nested), attributes (which cannot), raw content text, entities, DTDs, and other meta structures.
A common exchange format
JSON is a better data exchange format. XML is a better document exchange format. Use the right tool for the right job.
Many views of the one data
JSON does not provide any display capabilities because it is not a document markup language.
Self-Describing Data
XML and JSON have this in common.
Complete integration of all traditional databases and formats
(Statements about XML are sometimes given to a bit of hyperbole.) XML documents can contain any imaginable data type - from classical data like
text and numbers, or multimedia objects such as sounds, to active formats like
Java applets or ActiveX components.
JSON does not have a <[CDATA[]]> feature, so it is not well suited to act as a carrier of sounds or images or other large binary payloads. JSON is optimized for data. Besides, delivering executable programs in a data-interchange system could introduce dangerous security problems.
Internationalization
XML and JSON both use Unicode.
Open and extensible
XML’s one-of-a-kind open structure allows you to add other state-of-the-art
elements when needed. This means that you can always adapt your system to embrace
industry-specific vocabulary.
Those vocabularies can be automatically converted to JSON, making migration from XML to JSON very straightforward.
XML is easily readable by both humans and machines
JSON is easier to read for both humans and machines.
XML is object-oriented
Actually, XML is document-oriented. JSON is data-oriented. JSON can be mapped more easily to object-oriented systems.
XML is being widely adopted by the computer industry
JSON is just beginning to become known. Its simplicity and the ease of converting XML to JSON makes JSON ultimately more adoptable.
What Does JSON Look Like?
- Here's information about a person, his website, and his email, all structured as JSON:
{
"id": "0001",
"type": "donut",
"ppu": 0.55,
"batters": {
"batter": [
{
"id": "1001",
"type": "Regular"
},
]
},
"topping": [
{
"id": "5003",
"type": "Chocolate"
},
{
"id": "5004",
"type": "Maple"
}
]
}
How is the Data in JSON Extracted?
- Very easy: (suppose the variable "data" holds the above JSON data)
data.id returns "001"
Tags