JSON
What is JSON?
JSON, or JavaScript Object Notation, is a format used for serializing and transmitting structured data over a network connection. It is primarily used to transmit data between a server and web applications. Web services and APIs use JSON format to provide public data.
Common Uses of JSON
JSON is commonly used to facilitate data transfers in web applications between a client, such as a browser and a server. For example when you fill out a web form. The form data is converted from HTML to Javascript objects to JSON objects and sent to a remote web server for processing.
When certain companies make their data public for other applications, the information is formatted in JSON. This way, any application, regardless of language, can collect and use the data.
Popular web APIs that utilize JSON is:
JSON Syntax
JSON’s appearance is similar to that of JavaScript objects since JSON is from the JavaScript programming language.
{
"student": {
"name": "Rumaisa Mahoney",
"age": 30,
"fullTime": true,
"languages": [ "JavaScript", "HTML", "CSS" ],
"GPA": 3.9,
"favoriteSubject": null
}
}
- The curly braces,
{..}
, hold objects. - The square brackets,
[..]
, hold arrays. - Data is stored in key-value pairs separated by a colon,
:
. - Every key-value pair is separated from another pair by a comma,
,
. Similarly, just like arrays are separated by a comma. - JSON property key names must be in double-quoted
(" ")
.
JSON Data Types
A JSON data type must be one of the following:
- string
- number
- object
- array
- boolean
- null