stleary / JSON-java

A reference implementation of a JSON package in Java.
http://stleary.github.io/JSON-java/index.html
Other
4.53k stars 2.56k forks source link

json only contains value should be supported #500

Closed Alanscut closed 4 years ago

Alanscut commented 4 years ago

Hi @stleary ,

JSON RFC4627 requires the json text should be object or array in section 2, after RFC 7158, it changed to JSON-text = ws value ws, and added some simple json example in section 13:

   "Hello world!"

   42

   true

json parser RFC 8259 seciton 9 requires that A JSON parser MUST accept all texts that conform to the JSON grammar. so I think we should support the simple json that only contains value like above. and I'm happy to help write this feature if you need. What do you think?

Alan Wang

stleary commented 4 years ago

@Alanscut No objections if you want to add this feature. Unit tests will be needed. The wiki pages have more information about adding code to the project. Let me know if you have any questions.

johnjaylward commented 4 years ago

@Alanscut @stleary . this is already supported through the https://github.com/stleary/JSON-java/blob/master/JSONTokener.java

See https://github.com/stleary/JSON-java/issues/238#issuecomment-225102417

stleary commented 4 years ago

@johnjaylward, thanks I had forgotten about this. Closing the issue based on the reason cited above.

johnjaylward commented 4 years ago

@stleary it may make sense to add a note to the README or to make a Wiki page with samples.

stleary commented 4 years ago

Sure, does anyone want to propose some text?

Alanscut commented 4 years ago

Thanks @johnjaylward and @stleary , I have sumbitted a PR to update README, does anyone besides collaborator have permission to modify the wiki?

stleary commented 4 years ago

The wiki pages will be maintained in this repo: https://github.com/stleary/JSON-Java-Wiki-Pages Feel free to submit a pull request there.

stleary commented 4 years ago

Closed due to readme change accepted, and wiki page repo set up.