What does JSON mean?
JSON stands for JavaScript Object Notation. It is a plain text format. It was born from the JavaScript language, but almost every language can read it. Think of it as a neat form with labels and answers, like "name: Sam".
Why is it used?
- Websites and apps use it to send data to each other. A system that lets programs talk is called an API.
- It is used in settings files, such as
package.jsonorcomposer.json. - It is easy for people to read and easy for computers to read.
What it looks like
{
"name": "Sam",
"age": 12,
"student": true,
"hobbies": ["chess", "football"],
"address": {
"city": "Pune"
}
}
This describes one person. Each line is a pair: a name (called a key) and its value.
The building blocks
- Object: a group of pairs inside curly braces
{ }. - Array: a list inside square brackets
[ ]. - String: text inside double quotes, like
"Sam". - Number: a number with no quotes, like
12. - Boolean:
trueorfalse. - null: means "nothing here".
Rules to remember
- Keys must be in double quotes. Single quotes are not allowed.
- Separate items with commas.
- Do not put a comma after the last item.
- Comments are not allowed in plain JSON.
- Every opening bracket needs a closing one.
How to check your JSON
- Copy your text.
- Paste it into a JSON validator. This is a free online tool that finds mistakes. Many code editors check JSON as you type.
- Fix any line it points to.
Warning: Do not paste private data, such as passwords, into online tools.
Tip: A missing comma or an extra comma is the most common JSON mistake.
If a settings file on your hosting will not load, ask support for help.
Quick recap
- JSON is a text format for sharing data.
- It uses key and value pairs, objects and arrays.
- Keys and text use double quotes.
- Watch your commas and brackets.
- Use a validator to find mistakes.