一个上传的地方,代码var data = jQuery.parseJSON(data); 这步出错。原因是多了一个不可见字符导致转码失败。 但是定位又找不到是哪里加的这个字符,所以请表格帮我写个正则,把这个过滤掉我的想法是在jQuery.parseJSON(data);之前用正则,只取可见字符进行转码(只匹配下面那些就行,用不到的字符全部过滤掉)大概涉及到的字符是这些:{"status":"true","info":{"name":"\u4fe1\u606f\u5b89\u5168\u5e08\u7406\u8bba\u8003\u8bd5\u590d\u4e60\u9898(\u6574\u7406).pdf","type":"courseware","size":297069,"key":"download","ext":"pdf","md5":"cf18eb2947ec4fbad4b1c039f9673585","sha1":"281edac612317cdc8ea8b84ce55df1048a9a25f9","savename":"58c6550dbca94.pdf","savepath":"\/Uploads\/courseware\/2017-03-13\/","userid":false,"create_time":1489392909,"file_id":31476}}js实在渣,写了半天写不对,不知道是写的代码有问题还是这样的思路不对。求表哥帮忙写一个
1 回答
千巷猫影
TA贡献1829条经验 获得超7个赞
let data = '{"status":"true","info":{"name":"\u4fe1\u606f\u5b89\u5168\u5e08\u7406\u8bba\u8003\u8bd5\u590d\u4e60\u9898(\u6574\u7406).pdf","type":"courseware","size":297069,"key":"download","ext":"pdf","md5":"cf18eb2947ec4fbad4b1c039f9673585","sha1":"281edac612317cdc8ea8b84ce55df1048a9a25f9","savename":"58c6550dbca94.pdf","savepath":"\/Uploads\/courseware\/2017-03-13\/","userid":false,"create_time":1489392909,"file_id":31476}}'
let json = JSON.parse(data.trim())
console.log(json)
试试
var data = jQuery.parseJSON(data.trim());
添加回答
举报
0/150
提交
取消