开发者

Making JSON not Escape Forward Slashes

开发者 https://www.devze.com 2023-03-06 14:12 出处:网络
This is an extenuation of this question: JSON: why are forward slashes escaped? So I understand why JSON escapes the forwards slashes when I create a JSONArray that has Strings that cont开发者_Go百科

This is an extenuation of this question:

JSON: why are forward slashes escaped?

So I understand why JSON escapes the forwards slashes when I create a JSONArray that has Strings that cont开发者_Go百科ain URLs (links) in each of its indices. I would like to now know how to make JSON not escape these forward slashes when I serialize a String like so:

[['documentary', 'http://www.google.com/#q=documentary']]

into a JSONArray. I was thinking of iterating through the Strings and removing any instance where there is a backslash, but I was wondering if there was a more efficient way of doing this or a way to have it so that the above string would not automatically be escaped as follows:

[['documentary', 'http:\/\/www.google.com\/#q=documentary']]

Thank you! Let me know if anything is unclear.


Is it json-simple that you are using? They have an open issue for this, no luck with a fix so far:

https://github.com/fangyidong/json-simple/issues/8

I just hacked their source code.

0

精彩评论

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