6

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 contain 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.

Community
  • 1
  • 1
Vinay
  • 6,204
  • 6
  • 38
  • 55

1 Answers1

1

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.

dnault
  • 8,340
  • 1
  • 34
  • 53
Igor Nazarenko
  • 2,184
  • 13
  • 10
  • 2
    No I am using org.json (for an Android app): http://developer.android.com/reference/org/json/package-summary.html – Vinay May 15 '11 at 20:44
  • Since there really is no other solution to this problem until they modify the source code themselves, this answer is the most suitable. – Vinay May 17 '11 at 22:19