Issue 100 in json-simple: escaped backslash results in new line character if followed by 'n' or 'r'

5 views
Skip to first unread message

json-...@googlecode.com

unread,
Sep 4, 2014, 5:26:45 AM9/4/14
to json-...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 100 by tobiasba...@gmail.com: escaped backslash results in new
line character if followed by 'n' or 'r'
https://code.google.com/p/json-simple/issues/detail?id=100

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


--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

json-...@googlecode.com

unread,
Sep 15, 2014, 4:12:29 AM9/15/14
to json-...@googlegroups.com
Updates:
Status: Invalid

Comment #1 on issue 100 by fangyid...@gmail.com: escaped backslash results
in new line character if followed by 'n' or 'r'
https://code.google.com/p/json-simple/issues/detail?id=100

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\"}" );

Reply all
Reply to author
Forward
0 new messages