美文网首页
小程序JSON.parse报错的坑

小程序JSON.parse报错的坑

作者: 花影_62b4 | 来源:发表于2021-03-19 17:21 被阅读0次

    let jsonStr=message.data;

     jsonStr = jsonStr.replace(" ", "");

     if (typeof jsonStr != 'object') {

              jsonStr = jsonStr.replace(/\ufeff/g, ""); //字符串转化JSON对象

            var info = JSON.parse(jsonStr);

    }

    这样转换一下info就是能正确转换后的json对象了

    相关文章

      网友评论

          本文标题:小程序JSON.parse报错的坑

          本文链接:https://www.haomeiwen.com/subject/rccbcltx.html