About JSON.parse?

var str = "a="""

var res = "{"" + str.replace(/"/g, "\\"").replace(/=/g, "":"") + ""}"

console.log("res", res) // {"a":"\"\""}
// 1:res?

console.log(res === "{"a":"\"\""}") // false
// 2:false

console.log("res1", JSON.parse(res)) // {a: """"}
What are the parsing rules for

question 3:JSON.parse ()?

Feb.10,2022

JSON.parse (jsonData) , jsonData is a string in JSON format, which serializes the string in JSON format into JSON data.


this is actually a problem of escaping single quotation marks and double quotation marks in a string. The "in
res is actually escaped, and there is no'


he parses the json string into a json object.

Menu