JSON in Action: JavaScript Examples [Part 1]

Опубликовано: 28 Май 2025
на канале: Компьютерная Академия top
177
like

JSON (JavaScript Object Notation) is a text format for storing and transmitting data. It's like a "language" understood by both humans and computers. Imagine you want to send a friend user information: name, age, email. In JSON, it would look like this:

{
"name": "Anna",
"age": 25,
"email": "anna@example.com",
"hobbies": ["drawing", "guitar"]
}

How is JSON structured?

— Data is stored in key:value pairs (e.g., "name": "Anna").
— Keys are always in quotation marks, values ​​can be a string, a number, true/false, an array (in square brackets []), or another object (in curly braces {}).
— All together, they're called a JSON object.

What is JSON used for?

— Data transmission. For example, when you fill out a form on a website, the data is often sent to the server in JSON format.
— Storing settings. Many programs save configurations in JSON files.
— Exchanging data between applications. For example, a weather app receives data from the server in JSON format and displays it to you.

Why is JSON so popular?

— Simplicity. It's easy to read, even for a beginner.
— Versatility. JSON is supported by almost all programming languages ​​(not just JavaScript!).
— Compactness. It has fewer unnecessary characters than XML (another data format).

JSON in JavaScript

JS has two methods for working with JSON:

1. JSON.stringify() — converts a JS object to a JSON string

const user = { name: "Anna", age: 25 };
const jsonUser = JSON.stringify(user); // '{"name":"Anna","age":25}'

2. JSON.parse() — converts a JSON string back to a JS object

const parsedUser = JSON.parse(jsonUser); // { name: "Anna", age: 25 }

Important! JSON is not code, but data. You cannot write functions or comments in it, only structured information.


На этой странице сайта вы можете посмотреть видео онлайн JSON in Action: JavaScript Examples [Part 1] длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Компьютерная Академия top 28 Май 2025, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 177 раз и оно понравилось like зрителям. Приятного просмотра!