JSON Refresher
The Basics
- JSON stands for JavaScript Object Notation
- It’s used for data representation and transmission
- Comprised of key-value pairs
- Text-based
- Minimal and portable
- Based on conventions seen in many languages
- Code for parsing JSON is available in many languages
Syntax
"key" : value
- Starts and ends with
{ }
- Keys are quoted
- Values can be strings, numbers, booleans, null, array, or objects containing these types
- Commas between pairs
- Syntax validators like https://jsonlint.com/ can be used
{
"firstName" : "Julie",
"lastName" : "Smith",
"course" : "Web Development",
"grade" : 92
}
How to Indicate an Array in JSON
Use the [ ]
notation to indicate an array.
{
"firstName" : "Julie",
"lastName" : "Smith",
"course" : "Web Development",
"grades" : [92,88,91,85]
}