tags:

views:

49

answers:

1

I'm using json2.js to create a JSON object which JQUERY posts to the Server. The object looks like:

[{"locationID":"16","locationDesc":"XXXX"}, {"locationID":"111","locationDesc":"XXXX"}, {"locationID":"12","locationDesc":"XXXX"}, {"locationID":"11","locationDesc":"XXXX"}]

Problem here is that XXXX sometimes contains quotes like "we're'" etc.... How should I handle this? Do you I escape somewhere or encode in some way?

Thanks

+1  A: 

You don't need to scape single quotes in JSON, you should only care about double quotes.

Here is the syntax diagram of a valid JSON string:

JSON string

You can also make sure that your JSON is valid using this tool.

CMS
is there something in json2 or jquery that will do this for me? escaping?
AnApprentice
Yes, and that something is the JSON encoder. It's not your job to think about it.
hobbs