js中打印出的示例:

执行

console.log(JSON.stringify(d).toString()),得到以下信息:
{"businessNumber":"HT-2019001","filesInfo":"[{\"fileName\":\"test.jpg\",\"groupName\":\"group1\",\"fdfsId\":\"M00/00/00/rBMBBERDSsGAWFZFAAEe88kVsg8661.jpg\"},{\"fileName\":\"test02.sql\",\"groupName\":\"group1\",\"fdfsId\":\"M00/00/00/rBMAA12ENqmAERVQAAAfFFZ78oA526.sql\"}]"}
console.log(JSON.stringify(d).toString().replace(new RegExp("\\\\\"","gm"),"\"")),得到以下信息:
{"businessNumber":"HT-2019001","filesInfo":"[{"fileName":"test.jpg","groupName":"group1","fdfsId":"M00/00/00/rBMBBERDSsGAWFZFAAEe88kVsg8661.jpg"},{"fileName":"test02.sql","groupName":"group1","fdfsId":"M00/00/00/rBMAA12ENqmAERVQAAAfFFZ78oA526.sql"}]"}

结论:js中的json串出现单个反斜杠 \ 时,替换需要用 \\\\ 。

GitHub 加速计划 / js / json
18
5
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:3 个月前 )
2d42229f * Support BSON uint64 de/serialization Signed-off-by: Michael Valladolid <mikevalladolid@gmail.com> * Treat 0x11 as uint64 and not timestamp specific Signed-off-by: Michael Valladolid <mikevalladolid@gmail.com> --------- Signed-off-by: Michael Valladolid <mikevalladolid@gmail.com> 4 天前
1809b3d8 Signed-off-by: Niels Lohmann <mail@nlohmann.me> 5 天前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐