sebdwis / json-simple

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

Parser doesn't raise exception on space delimited values in JSON arrays and objects #16

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Define two strings "[1 2 3]" and "{\"key1\" \"val1\" \"key2\" \"val2\"}"
2. Pass the strings to org.json.simple.parser.JSONParser.parse()
3. No ParseException will be raised, the parser returns a valid JSONArray /
JSONObject.

What is the expected output? What do you see instead?
JSON arrays and objects have their values/key-value pairs separated by
commas. The parser, however, seems also to accept tokens that are separated
by space only. The same happens to the ":" operator for object key-value pairs.

What version of the product are you using? On what operating system?
JSON.simple 1.1 / Java 1.6 / Linux

Please provide any additional information below.

Original issue reported on code.google.com by vladimir...@gmail.com on 5 Jan 2010 at 1:35

Attachments:

GoogleCodeExporter commented 8 years ago
Yes, JSON.simple has a broader allowed inputs other than the spec. That is not a
violation of the spec (see
http://code.google.com/p/json-simple/wiki/DecodingExamples#Notes_-_Multithreadin
g_and_extensions
and relevant comments).

But it's useful to add a "strict" mode to the parser to support the validation 
of inputs.

Thanks.

Original comment by fangyid...@gmail.com on 6 Jan 2010 at 12:10

GoogleCodeExporter commented 8 years ago
I thank you for this clarification. I've been using JSON.simple for quite some 
time
and only now I did find out about this special behaviour. I discovered the 
"bug" when
I wrote a small client app for querying and testing JSON-RPC 2.0 servers. There 
I use
the library to validate and parse JSON input directly by the user.

Anyhow, while it would be nice to have a strict mode, I can also happily live 
with this.

Original comment by vladimir...@gmail.com on 6 Jan 2010 at 9:14

GoogleCodeExporter commented 8 years ago
Issue 43 has been merged into this issue.

Original comment by fangyid...@gmail.com on 29 Nov 2011 at 3:21

GoogleCodeExporter commented 8 years ago
Issue 83 has been merged into this issue.

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