JSON
-
javascript JSON 메소드를 알아보자!Javascript/JS 문법 2023. 3. 10. 15:32
📌 JSON.stringify() : 배열이나 객체 값 등 들어온 값들을 모두 문자열 처리합니다. console.log(JSON.stringify({ x: 5, y: 6 })); // "{"x":5,"y":6}" 📌 JSON.parse() : 배열이나 객체 값 등 들어온 값들을 모두 문자열 처리합니다. const json = '{"result":true, "name":"woony"}'; const obj = JSON.parse(json); console.log(obj.result); //true console.log(obj.name); //result