Problem:
For a certain request, I occasionally receive a dirty raw JSON response like the following:
{
"imdbtitle":"Quantum of Solace",
"type":"movie",
...
"plot": "Is there solace in revenge? Bond and "M" sniff a shadowy international network of
power and corruption reaping billions. As Bond pursues the agents of an assassination
attempt on "M," all roads lead to Dominic Greene, a world-renowned developer of green
technology. Greene, a nasty piece of work, is intent on securing a barren area of Bolivia in
exchange for assisting a strongman stage a coup there. The CIA looks the other way, and only
Bond, with help from a retired spy and from a mysterious beauty, stands in Greene's way.
"M" wonders if she can trust Bond, or if vengeance possesses him. Beyond that, can anyone
drawn to Bond live to tell the tale?"
}
Notice the unescaped "M"
strewn about in multiple places in the value for the key plot
.
More Info:
I am not in control of the response received (using a Rapid API service), so I cannot clean this data manually in the DB.
I am using Node Fetch and the error was thrown by their built in .json()
parser function.
I am able to manually access the raw response from the server to parse manually, but am not quite sure what the best approach would be to sanitize in a way accounts for all unescaped double quotes that are sure to be tossed at me in other future responses from this API.
Any help is greatly appreciated :)
question from:
https://stackoverflow.com/questions/65648218/is-there-a-way-to-clean-a-json-response-that-includes-unescaped-double-quotes-fo 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…