JSON
The LMC API uses JSON to transmit data between the backend and the fronted.
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 arrays (or other serializable values). It is a commonly used data format with diverse uses in electronic data interchange, including that of web applications with servers.
The following is an example JSON data structure that (partially) describes a device in the LMC:
{ // an object is wrapped in curly braces
"id": "20c00759-aaaa-bbbb-cccc-092158681e3e", // the syntax is "attribute": <value>, comma-separated
"siteName": "Würselen", // strings are "quoted"
"siteId": "883a7141-aaaa-bbbb-cccc-627bf8c32b5e",
"location": { // "location" is a nested object
"latitude": 50.8050285, // numbers are not quoted
"longitude": 6.1493351
},
"customFields": [], // a list is wrapped in square braces (this list is empty)
"status": {
"name": "Lancom-1781A",
"serial": "4003767318100050", // this is a "string", allthough it contains only numbers
"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>
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.