Notes
In JSON, values must be one of the following data types:
- a string
- a number
- an object (JSON object)
- an array
- a boolean
- null
JSON Strings
Strings in JSON must be written in double quotes.
{"make": "Tesla"}
JSON Numbers
Numbers in JSON must be an integer or a floating point.
{"year": 2022}
JSON Objects
Values in JSON can be objects.
{
"car": {
"make": "Tesla",
"model": "Model 3",
"year": 2022,
"color": "red"
}
}
JSON Arrays
Values in JSON can be arrays.
{
"employees": [
"John",
"Anna",
"Peter"
]
}
JSON Booleans
Values in JSON can be true/false.
{"active":true}
JSON null
Values in JSON can be null.
{"middlename":null}
Example
{
"title": "The Great Gatsby",
"author": "F. Scott Fitzgerald",
"publication_year": 1925,
"isbn": "9780743273565",
"publisher": {
"name": "Scribner",
"location": "New York"
},
"genres": ["Fiction", "Classic", "Literary"],
"ratings": {
"average": 4.2,
"count": 150
},
"is_available": true
}
In this example:
"title" represents the title of the book, which is set to "The Great Gatsby".
"author" represents the author of the book, which is set to "F. Scott Fitzgerald".
"publication_year" represents the year the book was published, set to 1925.
"isbn" represents the unique identifier of the book, set to "9780743273565".
"publisher" is an object containing information about the publisher, including "name" ("Scribner") and "location" ("New York").
"genres" is an array of strings representing the genres the book belongs to: "Fiction", "Classic", and "Literary".
"ratings" is an object containing information about the book's ratings, including the "average" rating of 4.2 and the total "count" of 150 ratings.
"is_available" is a boolean value indicating whether the book is available, set to true