- [Instructor] In real world JSON data,
it's common to encounter structures with multiple layers.
For instance, an array,
in which each element is itself an object,
this file contains departure estimates for trains in the bay
area, rapid transit system in California,
the starting curly brace indicates that the overall
structure is an object,
but many of the keys have additional objects as their values
and some even have arrays as their values.
For instance, if I scroll down here,
the estimate key contains an array with three objects in it.
If the structure feels a little overwhelming, that's okay.
It can be challenging to make sense of everything
going on here.
Especially if you're new to JSON.
To get a feel for how all the pieces fit.
Let's build out our own nested structure together.
In the extremes.JSON file,
I want to create a JSON object with two keys,
highest peaks and lowest points.
The value for each key will be an array,
listing the highest peaks and lowest points in order.
I'll start by creating the basic structure.
My overall structure is an object,
so I'll start with curly braces
and then I want a highest peaks key,
and I want the value to be an array.
So I'll start some square brackets
and I'll press enter.
And for now, I'll just leave those square brackets empty.
Now I want another key.
So I need to put a comma at the end of the value
for the first key
and that's the end of the closing square bracket.
And then on a new line,
I want another key called lowest points.
And again, I'll give this an empty array as its value.
This is my basic structure.
My next step is to fill in the next level of data,
which is the array value for each key within the square
brackets for highest peaks, I'll add Mount Everest.
and then K2,
and then Kangchenjunga.
And then for lowest points,
my values are Dead Sea,
Lake Assal, and Turpan Pendi.
Now I have a nested structure,
which is an object containing arrays as values.
Nesting gives JSON a lot of power because any value
could itself be another object or array.
You may hear JSON referred to as a notation
for creating structured data
and nested arrays and object are at the heart
of those structures.