JavaScript - Escape double quotes

后端 未结 2 431
北海茫月
北海茫月 2020-12-01 14:17

How do you escape double quotes if the JSON string is the following?

var str = "[{Company: "XYZ",Description: ""TEST""}]&qu         


        
2条回答
  •  醉梦人生
    2020-12-01 14:44

    Here the inner quote is escaped and the entire string is taken in single quote.

    var str = '[{ "Company": "XYZ", "Description": "\\"TEST\\""}]';
    

提交回复
热议问题