Skip to content Skip to sidebar Skip to footer

Parsing Double Quotes Within Json

I'm trying to parse some JSON I'm receiving from a third-party API. The problem is that some of the JSON has quotes inside quotes, like this: var json = '{'sentence': 'My favorite

Solution 1:

That is not valid JSON, so you cannot do it with standard methods.

You either have to escape the quotes like this: "sport is \" " or else you need to write your own sanitizer

Solution 2:

Those quotes should be escaped -

"My favorite sport is \"dodgeball\"."

If it's a real service (not homework) this will be done properly. If it's homework, then go fix that bug in the service.

Post a Comment for "Parsing Double Quotes Within Json"