To get a feel of JSON, look at the example below:
{
"Name" : "Alice",
"Gender" : "Female",
"Age" : 11,
"Languages" : [ "English", "Japanese" ],
"LastKnownLocation" : {
"City" : "Kuala Lumpur",
"State" : "Selangor",
"Country" : "Malaysia"
},
"Alive" : true
}
"Name" : "Alice",
"Gender" : "Female",
"Age" : 11,
"Languages" : [ "English", "Japanese" ],
"LastKnownLocation" : {
"City" : "Kuala Lumpur",
"State" : "Selangor",
"Country" : "Malaysia"
},
"Alive" : true
}
Here is the same data in XML format:
<Name>Alice</Name>
<Gender>Female</Gender>
<Age>11</Age>
<Languages>
<Language>English</Language>
<Language>Japanese</Language>
</Languages>
<LastKnownLocation>
<City>Kuala Lumpur</City>
<State>Selangor</State>
<Country>Malaysia</Country>
</LastKnownLocation>
<Alive>true</Alive>
<Gender>Female</Gender>
<Age>11</Age>
<Languages>
<Language>English</Language>
<Language>Japanese</Language>
</Languages>
<LastKnownLocation>
<City>Kuala Lumpur</City>
<State>Selangor</State>
<Country>Malaysia</Country>
</LastKnownLocation>
<Alive>true</Alive>
The kinds of values supported by JSON are strings (
Name
and Gender
), numbers (Age
), objects (LastKnownLocation
), arrays (Languages
), booleans (true/false e.g. Alive
), and null.JSON offers the advantage that they can be used "natively" by languages such as Javascript. No need for an additional parsing library!
No comments:
Post a Comment