AAKASH
aakash-n0dev
Handling JSON
JAVASCRIPT
Introduction to JSON
JSON (JavaScript Object Notation) is
a lightweight data interchange format
used for storing and transporting
data.
It’s often used when data is sent from
a server to a web page.
JSON is language-independent, self-
describing, and easy to understand.
JSON Syntax
JSON data consists of name/value
pairs, similar to JavaScript object
properties.
A name/value pair includes a field
name (in double quotes), followed by
a colon and the corresponding value.
Unlike JavaScript, JSON names
require double quotes.
JSON Objects
JSON objects are enclosed in curly
braces {}.
Objects can contain multiple
name/value pairs.
JSON Arrays
JSON arrays are enclosed in square
brackets [].
An array can contain objects.
Converting JSON to Js Object
& Js Object to JSON
To convert a JSON string to a JavaScript object, use
JSON.parse().
To convert a JavaScript object to JSON format, use
JSON.stringify().
JS code to handle JSON data
from an API