JSON
JSON
“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’]
}]
}]’
console.log(JSON.parse(students))
</script>
DIFFERENCE b/w JSON and XML
JSON(JavaScript Object XML(Extensive Markup
Notation) Language)
2.It supports array and doesn’t use end tag. 2.It doesn’t supports array and uses start
and end tags.
4.It is a way of representing Objects 4. Its files are very easy to read as
compared to XML.
5.It’s less secured and supports only UTF- 5.It’s more secured than JSON and it
8 encoding supports various encoding .
2.JSON is faster. The XML software parsing process can take a long time.JSON uses
less data overall, so you reduce the cost and increase the parsing speed.
4.JSON uses a map data structure which is predictable and easy to understand data
model rather than XML’s tree.
5.XML is much more difficult to parse than JSON.JSON is parsed into a ready-to-use
JavaScript object.