Frankie Frankie - 2 months ago 20
Javascript Question

How to remove " from my Json in javascript?

I am trying to inject json into my backbone.js app. My json has

"
for every quote.

Is there a way for me to remove this?

I've provided a sample below:

[{"Id":1,"Name":"Name}]

Answer

Presumably you have it in a variable and are using JSON.parse(data);. In which case, use:

JSON.parse(data.replace(/"/g,'"'));

You might want to fix your JSON-writing script though, because " is not valid in a JSON object.