Great job! We can store some complicated objects in JSON files. Have a look at this example:
{
"author": {
"first_name": "Guido",
"last_name": "van Rossum"
},
"title": "An Introduction to Python",
"pages": 175,
"ISBN-10": 915215643
}
Here we have information about a book. What's the difference between this example and the previous ones? Inside our object, we have a key named author
, which has a nested JSON object passed as a value.
{
"first_name": "Guido",
"last_name": "van Rossum"
}
That nested object itself contains name-value pairs. If the book has multiple objects, we can group the author values into one array, like this:
{
"author": [
{
"first_name": "Guido",
"last_name": "van Rossum"
},
{
"first_name": "Alex",
"last_name": "Smith"
}
]
}