开发者

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:

jQuery, Quotes, characters etc are breaking my JSON


(source: json.org)

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜