JSON is a format for exchanging information between different programs. It’s like a list of things, where each thing has a name and a value.
Object
Imagine you have an object. An object consists of curly braces {}
and inside it, there are names and values separated by commas. For example, you can have an object that contains a person’s name and age:
{
"name": "Jeffey",
"age": 34
}
Array
An array is like a list. It is written inside square brackets []
and contains values that are also separated by commas. Here is an example of an array of fruit:
["black", "red", "yellow"]
The values in JSON can be strings (text), numbers, boolean values (like “true” or “false”), other objects, arrays, or even nothing (null
).
Strings are enclosed in double quotes "
. For example, "Hello"
is a string.
Numbers, boolean values, and null
are written without quotes. For example, 42
is a number, and true
is the boolean value “true”.
Why JSON?
JSON is easy to read and supported by many programming languages. It is used for exchanging information between programs and is a popular choice for data communication.