How can I put double quotes inside a string within an ajax JSON response?

Posted by karlthorwald on Stack Overflow See other posts from Stack Overflow or by karlthorwald
Published on 2010-04-28T19:06:45Z Indexed on 2010/04/28 19:17 UTC
Read the original article Hit count: 283

Filed under:
|
|
|

I receive a JSON response in an Ajax request from the server. This way it works:

{ "a" = "1", "b" = "hello 'kitty'" }

But I did not succeed in putting double quotes around kitty.

When I convert " to \x22 in the Ajax response, it is still interpreted as " by JavaScript and I cannot parse the JSON.

Should I also escape the \ and unescape later (which would be possible)?

How to do this?

Edit: I am not sure if i expressed it well: I want this string inside of "b" after the parse:

hello "kitty"

If necessary I could also add an additional step after the parse to convert "b", but I guess it is not necessary, there is a more elegant way so this happens automatically?

© Stack Overflow or respective owner

Related posts about JSON

Related posts about json-decode