Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

forward slashes are unnecessarily escaped #8

Open
GoogleCodeExporter opened this issue Apr 13, 2015 · 8 comments
Open

forward slashes are unnecessarily escaped #8

GoogleCodeExporter opened this issue Apr 13, 2015 · 8 comments

Comments

@GoogleCodeExporter
Copy link

System.out.println(JSONValue.toJSONString("a/b/c"));

yields

"a\/b\/c"

-------

So here's the deal. After asking this question
http://stackoverflow.com/questions/1580647, it looks like the JSON spec
allows but does not require forward slashes to be escaped. (see RFC4627
http://www.ietf.org/rfc/rfc4627.txt p.4) 

So technically this issue is not a bug... but it makes file paths look
really ugly.

Apparently the string "</" is problematic in a few circumstances (namely
inside <script> tags in HTML).

Is there any way you could change the behavior of json-simple so either
it's user-selectable whether forward slashes in strings are escaped, or you
only escape "</" to "<\/"? 


Original issue reported on code.google.com by jmsa...@gmail.com on 16 Oct 2009 at 10:23

@GoogleCodeExporter
Copy link
Author

Yes, we escape every slash to void issues in HTML (JSON is used in web 
applications
in most cases) and make the code simpler (and slightly efficient and reliable 
code,
without contextual condition handling). Actually JSON.simple focuses on 
supports in
communications between applications (such as web server and browser, distribute
computing), so reliable (100% SPEC compliance and bug free) and efficient are 
two
important consideration, while other features such as pretty printing is not 
supported. 

But I think this is a valid usability concern, so I am setting it as an 
enhancement,
which will be reviewed and may be implemented in the future. 

You are also encouraged to modify and improve the source code directly if you 
need it
right now.

Thanks.

Original comment by fangyid...@gmail.com on 17 Oct 2009 at 3:30

  • Changed state: Accepted
  • Added labels: Priority-Low, Type-Enhancement
  • Removed labels: Priority-Medium, Type-Defect

@GoogleCodeExporter
Copy link
Author

Issue 9 has been merged into this issue.

Original comment by fangyid...@gmail.com on 3 Nov 2009 at 12:33

@GoogleCodeExporter
Copy link
Author

We use it to encode/decode inter-application (twitter/our app) communication 
which contains quite a few URLs. 
Now to use this library we have to unescape some of the values unnecessarily. I 
do suggest to make this an 
option for the serializer.

Original comment by matthias...@gmail.com on 13 Apr 2010 at 3:41

@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

Issue 77 has been merged into this issue.

Original comment by jon.cham...@gmail.com on 10 Aug 2013 at 3:15

@GoogleCodeExporter
Copy link
Author

I am putting a base64 encoded image into a json object. All the slashes in the 
encoded string are escaped when calling toString(). Thats too bad! Provide a 
toString() and a toEscapedString() method, that the user can choose which one 
to use. :-) 

Original comment by christop...@googlemail.com on 13 Feb 2014 at 12:05

@GoogleCodeExporter
Copy link
Author

I have same issue escaping slash. 

Please, provide toString() and toEscapedString() method.

Original comment by abh0...@gmail.com on 8 May 2014 at 5:27

@ashitshah
Copy link

Facing the same problem as forward slashes are escaped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants