- [Instructor] The acronym JSON stands for
JavaScript Object Notation.
The JavaScript part of that name is pretty straightforward.
JavaScript is the programming language
whose syntax forms the basis of JSON syntax, however,
you don't need to know the JavaScript programming language
in order to use JSON.
The N, for Notation, is pretty self-explanatory.
Notation is just another way of saying
that this is a way of presenting information
with its own format and rules.
But what is the O mean, Object?
In this case, it's not a common sense of object,
meaning just a thing.
The word Object, in JavaScript Object Notation,
references a technical meaning of the word object.
In JavaScript, like in other programming languages,
an object is a collection of data that's similar to a list.
An object contains key value pairs
where the key is a label that can describe the data,
and the value is the data you're storing.
For instance, suppose I'm making a list
of my favorite foods.
My favorite fruit is a mango, my favorite vegetable
is an eggplant and my favorite drink is sparkling water.
I can make a list and specify a category
and then the favorite thing.
This is already most of the way there
to creating an object in JavaScript.
All I have to do is add the right punctuation,
so a JavaScript parser can understand the relationship
between the items I'm presenting and I have an object.
In a JavaScript object the label for a piece of data
is known as a key, the data itself is known as the value.
You'll often hear data and its label
referred to as a key value pair.
JSON is based on the way objects are written in JavaScript.
JSON uses key value pairs and JavaScript object style
punctuation, but with a few of its own rules added.
Here's the object I created on the left,
and here's how I would specify the same data,
using JSON, on the right.
Almost identical, with a few differences,
but it's not hard to see that JSON syntax
is modeled on the notation that JavaScript uses for objects.
There's another JavaScript data structure
that can be represented as JSON, that's an array.
An array is a list of values in order.
You don't specify keys in an array, just values,
and it uses slightly different punctuation,
but under the hood in JavaScript,
it's considered a type of object.
And, in fact, you can represent an array as JSON as well.