Json.stringify()

기본 문법

    JSON.stringify(value(, replacer(, space)))

JavaScript 값 또는 객체를 JSON 문자열로 변환, 선택적으로 rplacer에서 함수로 전달될 때 모든 값을 변환, 배열로 전달될 때 결과에 ​​특정 속성만 포함

console.log(JSON.stringify({ x: 5, y: 6 }));
// Expected output: "{"x":5,"y":6}"

바꾸기 기능을 사용할 때

function replacer(key, value) {
  if (typeof value === "string") {
    return undefined;
  }
  return value;
}

var foo = {foundation: "Mozilla", model: "box", week: 45, transport: "car", month: 7};
var jsonString = JSON.stringify(foo, replacer);

>{“주”:45,”월”:7}