Issue 101 in json-simple: JSONParser.parse() throws a parse exception on trailing and leading whitespace of a JSON String.

10 views
Skip to first unread message

json-...@googlecode.com

unread,
Sep 16, 2014, 2:18:44 AM9/16/14
to json-...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 101 by ashutosh...@gmail.com: JSONParser.parse() throws a parse
exception on trailing and leading whitespace of a JSON String.
https://code.google.com/p/json-simple/issues/detail?id=101

What steps will reproduce the problem?
1. Have a valid JSON string with trailing whitespace after the last '}'.
2. Parse it with JSONParser.parse or JSONValue.parse


Expected: If the JSON is valid it should be parsed as an object.
Seen: An NullPointerException or a ParseException is thrown with the
message:
Unexpected character () at (index after last '}' ).


JSON simple 1.1 on Java 1.6

Calling trim() on the json string before parsing won't throw the error.

This scenario happened when I was parsing JSON messages sent through UDP as
bytes and received in a fixed size byte[] buffer. Not realising that there
are whitespaces in front of the json string (The error is non descriptive,
doesn't show the character on which the parse error occurred is a space).

Should the parser call trim() implicitely?



--
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 16, 2014, 3:16:40 AM9/16/14
to json-...@googlegroups.com
Updates:
Status: Accepted

Comment #1 on issue 101 by fangyid...@gmail.com: JSONParser.parse() throws
a parse exception on trailing and leading whitespace of a JSON String.
https://code.google.com/p/json-simple/issues/detail?id=101

(No comment was entered for this change.)
Reply all
Reply to author
Forward
0 new messages