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}]

Solution 1:

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.

Solution 2:

Accepted answer is right, however I had a trouble with that. When I add in my code, checking on debugger, I saw that it changes from

result.replace(/"/g,'"')

to

result.replace(/"/g,'"')

Instead of this I use that:

result.replace(/(&quot\;)/g,"\"")

By this notation it works.

Solution 3:

var data = $('<div>').html('[{&quot;Id&quot;:1,&quot;Name&quot;:&quot;Name}]')[0].textContent;

that should parse all the encoded values you need.

Solution 4:

This is a simple way to replace &quot with what you need to change it - chars, strings etc.

function solve(input) {
   const replaceWith = '"' // e.g. replace &quot; by "
   const result = input.replace(/&quot;/g, replaceWith)
   return result;
} 

console.log(solve('{&quot;x&quot;:&quot;1&quot;,&quot;y&quot;:&quot;2&quot;,&quot;z&quot;:&quot;10&quot;}')
   

Solution 5:

The following works for me:

function decodeHtml(html) {
    let areaElement = document.createElement("textarea");
    areaElement.innerHTML = html;

    return areaElement.value;
}