JSON

tapata·2022년 3월 25일
0

JSON

  • 자료형 : number, string, boolean, array, object, null

Static methods

  • JSON.parse(text:string) : json 문자열을 JS 객체로 변환
  • JSON.stringify(object) : JS객체를 json 문자열로 변환
const json = '{"code":200, "message":"OK"}'
const obj = JSON.parse(json)

console.log(obj.code) // 200
console.log(obj.message) // OK

const str = JSON.stringify(obj) // 
console.log(str) // {"code":200, "message":"OK"}

References

profile
hello

0개의 댓글