let jsonStr=message.data;
jsonStr = jsonStr.replace(" ", "");
if (typeof jsonStr != 'object') {
jsonStr = jsonStr.replace(/\ufeff/g, ""); //字符串转化JSON对象
var info = JSON.parse(jsonStr);
}
这样转换一下info就是能正确转换后的json对象了
这样转换一下info就是能正确转换后的json对象了
本文标题:小程序JSON.parse报错的坑
本文链接:https://www.haomeiwen.com/subject/rccbcltx.html
网友评论