我有这个:
JSON.parse('{"130.00000001":{"p_cod":"130.00000001","value":"130.00000001 HDD Upgrade to 2x 250GB HDD 2.5\" SATA2 7200rpm"}}');
JSONLint说这是完全有效的json.但在执行时我有一个JSON.parse错误.
但是,如果我将我的代码更改为:
    JSON.parse('{"130.00000001":{"p_cod":"130.00000001","value":"130.00000001 HDD Upgrade to 2x 250GB HDD 2.5\\" SATA2 7200rpm"}}');
(注意双反斜杠)
它有效,但现在JSONLint说invalid json.
有人可以帮助理解这种行为吗?
Dea*_*vey 19
It's a difference between the wire format, and what you have to write in your code to get the wire format. When you declare this in code you need the double-\ in your literal so the string gets a single backslash (otherwise it will interpret \" as an escape sequence for just declaring a " and put that in your string). If you print out the value of the literal you will see a single backslash.
| 归档时间: | 
 | 
| 查看次数: | 26829 次 | 
| 最近记录: |