JSON
JSON
+4
Published Jun 2, 2022•Updated Apr 22, 2023
Contribute to Docs
JSON is commonly used for transferring data between clients and servers for
tasks such as web browsing or form submission. Some companies also use
JSON to allow their data to be accessed in other applications via API. Some
examples include:
• Google Maps
• Google Auth 2.0 Authentication
• Meta (formerly Facebook) Send API
• Spotify Music Web API
• LinkedIn Profile API
More can be learned about JSON by visiting json.org.
Syntax
{
"propertyOne": "valueOne",
"propertyTwo": "valueTwo",
"propertyThree": "valueThree",
}
Data is stored in an object, depicted by a pair of curly braces { }, and name-
value pairs are separated by a colon :. The pairs themselves are separated by a
comma ,. The following are data types that can be used:
Whitespace (e.g., spaces, tabs, line feeds, and carriage returns) is ignored
between names, values, and punctuation. The following four characters are all
considered whitespace: space, tab, line feed, and carriage return.
• While it is derived from from the JavaScript language, JSON itself is not
JavaScript.
• Trailing commas are forbidden.
• Although JavaScript names are not this strict, JSON property names
must be in double quotes.
Bad Practices
Below are two points regarding what should be avoided when using JSON
format:
Example
The following JSON example uses one level of nested objects, an array, and
each valid data type:
{
"make" : "Chevy",
"model" : "Silverado",
"miles" : 27500.5,
"year" : 2020,
"owner" : {
"firstName" : "John",
"lastName" : "Doe"
},
"features" : ["4WD", "Towing Package", "Lift Kit"],
"lease" : false,
"customizations": null
}