Extreme API with Python

Table Of Contents
Extreme API with Python
Page | 15
Part no.9036931-00 Rev AA February 2021
2.4 Understanding JSON
JSON (JavaScript Object Notation) is an open standard file format, defined in RFC 8259
(
HTTPS://tools.ietf.org/html/rfc8259), widely used to format the data transmitted and stored with
modern APIs and tools. Despite its name, JSON is language-independent and is used with whatever
programming language needed.
It is the preferred data format when working with REST APIs, but also is widely used as config files for
many applications (from your child’s Minecraft server settings to XMC settings, for example). It’s worth
to note that the first version of the JSON RFC (rfc 4627) registered the media type “application/json”.
JSON is a text format, human-readable tool that has been widely adopted to replace other standards
such as XML. The JSON format accepts basic data types such as number, string (delimited with double-
quotation marks), Boolean (true or false), array (ordered list of any type delimited with square brackets,
and each element separated with a comma), objects (collection of key-value pairs where the key is a
string) and empty value with the word null. A JSON object is always delimited between curly brackets or
square brackets. Each entry is separated with a comma, except for the last one for each object.
The following example was taken from Wikipedia (HTTPS://en.wikipedia.org/wiki/JSON#Example
):
{
"firstName": "John",
"lastName": "Smith",
"isAlive": true,
"age": 27,
"address": {
"streetAddress": "21 2nd Street",
"city": "New York",
"state": "NY",
"postalCode": "10021-3100"
},
"phoneNumbers": [
{
"type": "home",
"number": "212 555-1234"
},
{
"type": "office",
"number": "646 555-4567"
}
],
"children": [],
"spouse": null
}
Comments are not allowed in a JSON document.
Although JSON is not the only format for APIs, it is currently the most widely used. It comes with some
limitations that open doors for new formats. However, when you need a text file format with