JSON FORMAT
“name”:”Nandita”,
“favouriteNumber”:3,
“isProgrammer”:true,
“hobbies”:[“Music”,”Badminton”]
“friends”:[{
“name”:”Harsh”,
“favouriteNumber”:9,
“isProgrammer”:False,
“friends”:[‘Meena’,’Reena’,’Tina’]
}]
},
“name”:”Nancy”,
“favouriteNumber”:3,
“isProgrammer”:true,
“hobbies”:[“Weight Lifting”,”Bowling”]
“friends”:[{
“name”:”Harsh”,
“favouriteNumber”:null,
“isProgrammer”:False,
“friends”:[‘Meena’,’Reena’,’Tina’]
}]
<script type=”text/javascript”>
let students=
‘[
“name”:”Nandita”,
“favouriteNumber”:3,
“isProgrammer”:true,
“hobbies”:[“Weight Lifting”,”Bowling”]
“friends”:[{
“name”:”Harsh”,
“favouriteNumber”:9,
“isProgrammer”:False,
“friends”:[‘Meena’,’Reena’,’Tina’]
}]
}]’
[Link]([Link](students))
</script>
DIFFERENCE b/w JSON and XML
JSON(JavaScript Object XML(Extensive Markup
Notation) Language)
[Link] is based on JavaScript Language [Link] is derived from SGML(Standard
Generalized Markup Language)
[Link] supports array and doesn’t use end tag. [Link] doesn’t supports array and uses start
and end tags.
[Link] are easy to ready as compared to 3. Its documents are comparatively
XML difficult to read and interpret.
[Link] is a way of representing Objects 4. Its files are very easy to read as
compared to XML.
[Link]’s less secured and supports only UTF- [Link]’s more secured than JSON and it
8 encoding supports various encoding .
6. XML has to be parsed with an XML 6. JSON can be parsed by a standard
parser. JavaScript function.
7. JSON supports only 7. XML support many data types such as
text,Boolean,array,object and number data text, number, images, charts, graphs etc.
type. Moreover, XML offeres options for
transferring the format or structure of the
data with actual data.
8. Using JSON 8. Using XML
Fetch a JSON string Fetch an XML document
[Link] the JSON string Use the XML DOM to loop
through the document
Extract values and store in
variables
Why do we prefer JSON over XML?
1. JSON is less verbose. JSON has a compact style than XML and it is often more
readable. The Lightweight approach of JSON can make significant improvements.
[Link] is faster. The XML software parsing process can take a long [Link] uses
less data overall, so you reduce the cost and increase the parsing speed.
[Link] is straightforward and readable.
[Link] uses a map data structure which is predictable and easy to understand data
model rather than XML’s tree.
[Link] is much more difficult to parse than [Link] is parsed into a ready-to-use
JavaScript object.