JSON basics: serializing with stringify and deserializing with parse
JSON : JavaScript Object Notation
- Created an object named sungjun
js
const sungjun ={
name:'sungjun',
age:24,
eat: ()=>{
console.log('eat');
}
}- Serializing - turns an object into a string.
stringify(), a static function of JSON, converts an Object to JSON.
js
const json = JSON.stringify(sungjun);
console.log(json);
console.log(sungjun);- Deserializing - converts string data into a JavaScript object.
parse(), a static function of JSON, converts JSON to an Object.
js
const object = JSON.parse(json);
console.log(object);- #Deserializing
- #JSON : JavaScript Object Notation
- #Serializing