What is JSON?
JSON is one of the most important concepts in frontend and web development in general. Simply put:
JSON (JavaScript Object Notation) is a text format for storing and exchanging data, understandable to both humans and computers.
Example of JSON
javascript
{
"name": "Oleh",
"age": 25,
"isAdmin": false,
"skills": ["JavaScript", "React", "Node.js"],
"address": {
"city": "Kyiv",
"zip": 123456
}
}This is a regular JSON document. Essentially it is a string that holds structured data. Such data is easy to read and transmit over the network.
Where JSON is used
- Exchanging data between the client and the server The server sends JSON, the browser reads it:
javascript
fetch('/api/user')
.then(res => res.json())
.then(data => console.log(data.name));- Storing data in localStorage
javascript
const user = { name: 'Oleh', age: 25 };
localStorage.setItem('user', JSON.stringify(user));- Settings and configuration
(for example,
package.jsonin Node.js projects):
javascript
{
"name": "my-project",
"version": "1.0.0",
"scripts": {
"start": "node index.js"
}
}JSON syntax rules
| Rule | Description |
|---|---|
| Keys are always in double quotes | "name": "Oleh" |
| Strings are also in double quotes | "city": "Kyiv" |
| Only simple types are supported | string, number, boolean, null, object, array |
| No functions | function() {} → error |
No undefined and Symbol | they are ignored |
| Comma between elements | but not after the last element |
Basic JSON data types
| Type | Example |
|---|---|
| string | "Oleh" |
| number | 25 |
| boolean | true, false |
| null | null |
| object | { "a": 1, "b": 2 } |
| array | [1, 2, 3] |
Difference between JSON and JavaScript objects
| Feature | JSON | JavaScript object |
|---|---|---|
| Keys | Only in "double quotes" | Can be without quotes |
| Strings | Only "double" | 'single' or "double" |
| Types | Only simple ones (string, number, etc.) | Any (function, undefined, symbol) |
| Purpose | Storing/exchanging data | Working with data in JS code |
Converting between an object and JSON
javascript
const obj = { name: 'Oleh', age: 25 };
// object -> JSON
const json = JSON.stringify(obj);
console.log(json);
// '{"name":"Oleh","age":25}'
// JSON -> object
const parsed = JSON.parse(json);
console.log(parsed.name); // 'Oleh'Summary
| Parameter | JSON |
|---|---|
| Full name | JavaScript Object Notation |
| Format | Text |
| Used for | Storing and exchanging data |
| Typical operations | JSON.stringify() and JSON.parse() |
| Based on | JavaScript syntax |
| Supported | In all languages (Python, Java, C#, Go, etc.) |
In short
JSON is a universal data format that lets you transmit complex structures (objects, arrays and so on) as a plain text string.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.