jQuery, Quotes, characters etc are breaking my JSON
I'm using json2.js to create a JSON object which JQUERY posts to the Server. 开发者_如何学GoThe 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
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:
(source: json.org)
You can also make sure that your JSON is valid using this tool.
精彩评论