JSON.parse string with quotes

前端 未结 1 1880
旧时难觅i
旧时难觅i 2020-12-09 18:20

I have this:

JSON.parse(\'{\"130.00000001\":{\"p_cod\":\"130.00000001\",\"value\":\"130.00000001 HDD Upgrade to 2x 250GB HDD 2.5\\\" SATA2 7200rpm\"}}\');


        
相关标签:
1条回答
  • 2020-12-09 18:30

    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.

    0 讨论(0)
提交回复
热议问题