JSON is introduced on https://en.wikipedia.org/wiki/JSON as follows:
JavaScript Object Notation is an open standard file format, and data interchange format, that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and array data types (or any other serializable value). It is a very common data format, with a diverse range of > applications, such as serving as a replacement for XML in AJAX systems.
The following is an example JSON data structure that (partially) describes a device in the LMC:
{
"id": "20c00759-aaaa-bbbb-cccc-092158681e3e",
"siteName": "Würselen",
"siteId": "883a7141-aaaa-bbbb-cccc-627bf8c32b5e",
"location": {
"latitude": 50.8050285,
"longitude": 6.1493351
},
"customFields": [],
"status": {
"name": "Lancom-1781A",
"serial": "4003767318100050",
"mac": "00:a0:57:26:fa:33",
"ip": "192.168.59.9",
"model": "LANCOM 1781A",
"claimingState": "CLAIMED",
"heartbeatState": "ACTIVE"
}
}
|
---|
This object can be translated to the equivalent XML:
<device>
<id>20c00759-aaaa-bbbb-cccc-092158681e3e</id>
<siteName>Würselen</siteName>
<siteId>883a7141-aaaa-bbbb-cccc-627bf8c32b5e</siteId>
<location>
<latitude>50.805027</latitude>
<longitude>6.149335</longitude>
</location>
<customFields />
<status>
<claimingState>CLAIMED</claimingState>
<heartbeatState>ACTIVE</heartbeatState>
<ip>192.168.59.9</ip>
<mac>00:a0:57:26:fa:33</mac>
<model>LANCOM 1781A</model>
<name>Lancom-1781A</name>
<serial>4003767318100050</serial>
</status>
</device>
|
---|
Info |
---|
Exercise: Define an object with JSON that defines a point with an x = 8 and y = 15 coordinate, as well as a comment field Hello World . |