且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在有效的JSON JSON.parse错误

更新时间:2022-04-19 21:32:51

JSON.parse字符串报价

这应该是答案。总之,你不能只是复制粘贴JSON和单引号引用它,期望它的工作。您还需要确保反斜线都设有codeD。

That should be the answer. In short you cannot just copy paste JSON and quote it in single quotes and expect it to work. You would also need to make sure the backslashes are encoded.

因此​​,JSON的的实际上是有效的。但它不再是有效的,如果你把它复制粘贴到一个js文件。它有做怎样的javascript连接字符串中的codeS反斜杠。

So the JSON is in fact valid. But it is no longer valid if you copy paste it into a js file. It has to do with how javascript encodes backslashes in strings.