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

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

Open
GoogleCodeExporter opened this issue Jan 20, 2016 · 4 comments

Comments

@GoogleCodeExporter
Copy link

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
Copy link
Author

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

  • Changed state: Accepted
  • Added labels: Type-Enhancement
  • Removed labels: Type-Defect

@GoogleCodeExporter
Copy link
Author

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
Copy link
Author

Issue 43 has been merged into this issue.

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

@GoogleCodeExporter
Copy link
Author

Issue 83 has been merged into this issue.

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

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

1 participant