JSON(JavaScript Object Notion)은 Javascript 객체 문법으로 구조화된 데이터를 표현하기 위한
문자
기반의 표준 포맷
JSON.parse() 는 JSON 문자열의 구문을 분석하고, 그 결과에서 JavaScript 값이나 객체를 생성하여 변환
const userStr = '{ "nickname" : "rockbell89" , "age": 34}'
coust user = JSON.parse(userStr);
console.log(user.nickname) // output : rockbell89
JSON.stringfy() 는 JavaScript 값이나 객체를
JSON 문자열
로 변환
const user = { nickname : 'rockbell89' , age: 34 }
JSON.stringfy(user); // output : '{ "nickname" : "rockbell89" , "age": 34}'
toJSON()은 Date 객체의 문자열 표현을 반환
const event = new Date('August 19, 1975 23:15:30 UTC');
const jsonDate = event.toJSON();
console.log(jsonDate); // output: 1975-08-19T23:15:30.000Z