Abedeljalil / json-simple

Automatically exported from code.google.com/p/json-simple
Apache License 2.0
0 stars 0 forks source link

escaped backslash results in new line character if followed by 'n' or 'r' #100

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

Decode a string that contains an escaped backslash followed by 'n' or 'r' like 
this

JSONObject jsonObject = (JSONObject) JSONValue.parse( "{\"path\" : 
\"C:\\nothing.png\"}" );
String path = (String) jsonObject.get( "path" );
System.out.println( path );

What is the expected output? What do you see instead?

The output should be: 

C:\nothing.png

But instead it is: 

C:
othing.png

What version of the product are you using? On what operating system?

Version 1.1.1 on Windows 8.1 x64

Original issue reported on code.google.com by tobiasba...@gmail.com on 4 Sep 2014 at 9:26

GoogleCodeExporter commented 8 years ago
Your slash is escaped by Java in this example. The correct code should be the 
following:

JSONObject jsonObject = (JSONObject) JSONValue.parse( "{\"path\" : 
\"C:\\\\nothing.png\"}" );

Original comment by fangyid...@gmail.com on 15 Sep 2014 at 8:12