cover-img

JSON

20 January, 2023

1

1

0

Understanding JSON

JSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy for humans to read and write and for machines to parse and generate. It is a standard format for data interchange. It is commonly used in web development to transmit data between a server and a web application or between different parts of a web application.

In JavaScript, JSON can be used in two main ways:

  1. Parsing JSON data: JSON data can be parsed (converted from its string format to a JavaScript object) using the JSON.parse() method. For example:
let jsonString = '{"name":"John", "age":30}';
let jsonObject = JSON.parse(jsonString);
console.log(jsonObject.name); // Output: "John"
  1. Creating JSON data: JavaScript objects can be converted to a JSON string using the JSON.stringify() method. For example:
let jsonObject = {name: "John", age: 30};
let jsonString = JSON.stringify(jsonObject);
console.log(jsonString); // Output: '{"name":"John","age":30}'

It's worth noting that JSON is a subset of JavaScript so that any JSON data can be used in JavaScript without any additional work. However, JSON data is often used with Asynchronous JavaScript programming to transfer data between a web application and a server, as it is lightweight and easy to parse.

Further Reading

https://www.freecodecamp.org/news/what-is-json-a-json-file-example/


1

1

0

ShowwcaseHQ

San Francisco, CA, USA

Showwcase is where developers hang out and find new opportunities together as a community
Tapas Adhikary
Educator @tapaScript | Teaching JavaScript/React/FullStack | Writer | YouTuber | Founder CreoWis

More Articles

Showwcase is a professional tech network with over 0 users from over 150 countries. We assist tech professionals in showcasing their unique skills through dedicated profiles and connect them with top global companies for career opportunities.

© Copyright 2024. Showcase Creators Inc. All rights reserved.