Sitemap
Towards Dev

A publication for sharing projects, ideas, codes, and new theories.

JSON

2 min readJan 17, 2024

--

What is Json ?

JSON, which stands for JavaScript Object Notation, is a lightweight data interchange format. It is easy for humans to read and write, and it’s easy for machines to parse and generate. JSON is often used to transmit data between a server and a web application, as an alternative to XML.

Key Features of JSON:

  1. Syntax: JSON has a simple and easy-to-read syntax, consisting of key-value pairs.
  2. Data Types: JSON supports various data types, including strings, numbers, objects, arrays, boolean, and null.
  3. Object:An object in JSON is an unordered collection of key-value pairs. Keys are strings, and values can be strings, numbers, objects, arrays, boolean, or null.

Example of a simple JSON object:

{
"name": "John Doe",
"age": 30,
"isStudent": false,
"courses": ["Math", "History", "English"]
}

JSON typically involves two main operations: serialization and deserialization.

Get sunny Gupta’s stories in your inbox

Join Medium for free to get updates from this writer.

Serialization:Serialization is the process of converting data structures or objects into a JSON format.

Serialization (Object to JSON):

const myObject = {
name: "John Doe",
age: 30,
isStudent: false,
courses: ["Math", "History", "English"]
};

const jsonString = JSON.stringify(myObject);
console.log(jsonString);

Deserialization: deserialization is the process of converting JSON back into data structures or objects that your programming language can work with.

Deserialization (JSON to Object):

const jsonString = '{"name":"John Doe","age":30,"isStudent":false,"courses":["Math","History","English"]}';

const myObject = JSON.parse(jsonString);
console.log(myObject);

Sending data from a server to a client using JSON typically involves the server converting its data into a JSON format and then transmitting it to the client. The client can then parse the JSON data to extract the information. The communication can occur over HTTP, WebSocket, or any other suitable protocol.

Thank you

--

--

sunny Gupta
sunny Gupta

Written by sunny Gupta

Software Engineer , , Writer for Towards Dev

Towards Dev
Towards Dev

Published in Towards Dev

A publication for sharing projects, ideas, codes, and new theories.