what is JSON ?
• JSON - JavaScript Object Notation
• JSON is a lightweight format for storing and transporting data.
• JSON is often used when data is sent from a server to web page
• JSON is language independent
The JSON format is almost identical to JavaScript objects.
• In json keys MUST be in strings, written with double quotes
• In JavaScript object, keys can be strings, numbers, or identifier names
In JSON, values must be one of the following data types:
- string
- number
- object (JSON object)
- array
- boolean
- null
In javaScript object , valuse must be one of the following data types:
- string
- number
- object (JSON object)
- array
- boolean
- null
- function
- date
- undefined
🚥JSON.stringify( )
When sending data to a web server, the data has to be a string.
So thats why while before sending data we need to Convert it from a JavaScript object to a JSON
To make this happen we need JSON.stringify( ).
🚥JSON.parse( )
Likewise while we receiving data from a web server, the data is always a string.
So we need to Parse the data into javascript object to use the data in out applications.
And for this action we need to use JSON.parse()
Top comments (0)