JSON.stringify()和JSON.parse()
2021-02-11 08:15
                         标签:log   字符串解析   class   tran   font   pre   style   bsp   转换    JSON.stringify()和JSON.parse() JSON.stringify() 定义:将对象转换为json字符串。 使用: JSON.parse() 定义:将json字符串解析为对象。 使用:   JSON.stringify()和JSON.parse() 标签:log   字符串解析   class   tran   font   pre   style   bsp   转换    原文地址:https://www.cnblogs.com/xieZhao/p/13045475.html   const obj = { a: 1, b: 2 };
      const newObj = JSON.stringify(obj);
      console.log(newObj);
      // {"a":1,"b":2}
      const obj = { a: 1, b: 2 };
      const newObj = JSON.stringify(obj);
      const traNewObj = JSON.parse(newObj);
      console.log(traNewObj);
      // {a: 1, b: 2}
文章标题:JSON.stringify()和JSON.parse()
文章链接:http://soscw.com/index.php/essay/53953.html