Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove " from my Json in javascript?

Tags:

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}] 
like image 973
Frankie Avatar asked Feb 11 '12 23:02

Frankie


People also ask

How do you know if a tick head is still in you?

It typically looks like a small, dark-colored fleck. It may look like a splinter if it's just the tick's mouthparts. For an additional sign of a tick head still being stuck, you may also inspect the tick's body to see if it looks like pieces of the head broke off.

What do you do if a tick head is stuck in your skin?

Clean the area of the tick bite with rubbing alcohol. Using a sterilized tweezer, gently attempt to remove the tick's head with steady, strong pressure as you pull outward. If a sterilized tweezer doesn't work, you may also try to use a needle to widen the area of the tick bite to try to get the head out.

How do you remove a tick with Vaseline?

Do not try to kill, smother, or lubricate the tick with oil, alcohol, petroleum jelly, or similar material while the tick is still embedded in the skin.


2 Answers

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.

like image 84
Niet the Dark Absol Avatar answered Sep 21 '22 15:09

Niet the Dark Absol


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.

like image 32
efirat Avatar answered Sep 21 '22 15:09

efirat