如何将转义后的json数据还原?
转义后的json数据是这样的:
修改问题:
我把刚刚的JSON修改为了字符串形式:
var xxx = "{"after":{"author":"wb-zfr217592","description":"自定义配置","directoryId":"10","id":0,"logo":"http://apires-api-and-package-doc-bucket.cn-hangzhou.oss-cdn.aliyun-inc.com/b8e0c9438a31485d90a3cd0c9195205b/闃跨嫺.jpg","openAppPackageList":[{"forced":false,"packageCode":"2013051400046413_AOPT"},{"forced":false,"packageCode":"2013110800034967_AOPT"},{"forced":true,"packageCode":"01071000100077777777"}],"sortLevel":2,"status":0,"strengths":"去玩儿wer","templateId":"1","templateName":"支付应用"},"before":{"author":"wb-zhengyuefeng","description":"自定义配置","directoryId":"10","gmtCreate":1484733992000,"gmtModified":1486975760000,"id":1,"logo":"http://apires-api-and-package-doc-bucket.cn-hangzhou.oss-cdn.aliyun-inc.com/b8e0c9438a31485d90a3cd0c9195205b/闃跨嫺.jpg","openAppPackageList":[{"forced":true,"packageCode":"01071000100077777777","packageDesc":"芝麻信用借还","packageName":"芝麻信用借还"},{"forced":true,"packageCode":"2013051400046413_AOPT","packageDesc":"测试接口包-2013051400046413_AOPT","packageName":"2013051400046413_AOPT"},{"forced":false,"packageCode":"2013110800034967_AOPT","packageDesc":"测试接口包-2013110800034967_AOPT","packageName":"2013110800034967_AOPT"}],"sortLevel":2,"status":1,"strengths":"去玩儿wer","templateId":"1","templateName":"支付应用"}}";
我自身尝试使用JSON.parse(xxx),和JSON.parse(xxx).replace('"', '"'),浏览器都报错
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
json解析之前使用replace替换一下
还是把它转为string,然后转义回来,再转为json,类似:
JSON.parse(JSON.stringify(你的json).replace('"', '"'))
上传的时候回转义,看图片。