stleary / JSON-java

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

Unclear relevance relative to other JSON libraries (particularly javax.json) #702

Open Chealer opened 1 year ago

Chealer commented 1 year ago

Our team needs to receive and send JSON and wants to use a JSON library to facilitate that. org.json provides org.json.JSONObject while javax.json-api provides javax.json.JsonObject. The purposes of both libraries are clearly similar, and while there are obvious differences like licencing (this one is public domain), it takes time for evaluators to determine how to choose between these 2 options. And there are more, including Gson and Jackson.

Please provide a comparison, either as a feature table or as free-form text to help making a choice. If a third-party offers a neutral comparison, linking to it could suffice. If not, creating a comparison which focuses on comparing to javax.json-api would already be a good start. I would prioritize listing advantages of org.json, whether in terms of performance, flexibility or simplicity, but disadvantages would also help greatly.

A few resources already help:

madhavgupta2011 commented 1 year ago

The following table might help in the difference between org.json and javax.json

org.json javax.json
Package org.json javax.json
JSON Processing API Version N/A (Not a formal API) Java API for JSON Processing (Version 1.1)
Parsing Provides a simple and flexible JSON parser Provides a streaming and object model JSON parser
Writing Supports writing JSON objects and arrays Supports writing JSON objects and arrays
Size Lightweight Standard (part of Java EE and Java SE)
Dependencies Standalone library, no external dependencies Part of Java EE and Java SE, no external dependencies
Streaming Does not support streaming JSON processing Supports streaming JSON processing
Conformance May not fully conform to the JSON standard Fully conforms to the JSON standard
Performance Generally considered slower Generally considered faster
Popularity Widely used, especially in older Java projects Gaining popularity, recommended for new projects
stleary commented 1 year ago

@madhavgupta2011 Thank you, this is very helpful. I will look into incorporating this into the docs part of the project. Looks like streaming support and Conformance needs to be worked on. Generally considered slower? Really?

johnjaylward commented 1 year ago

The following table might help in the difference between org.json and javax.json

I'm not sure I'd agree with a lot of that comparison.

  1. The API for org.json is well defined, although not "formal". Android currently uses the same namespace and API from this project, albeit an older iteration of it.
  2. org.json fully conforms on the JSON spec for input and output. The JSON Spec specifically states that parsing of JSON may be more lax and still be conforming, while output must meet exact specifications, which org.json does.
  3. org.json support streaming by using the JSONTokener class directly, although it may not be as flexible as javax.json streaming. Unless you are implying event based streaming like an XML streaming parser may provide...
  4. I'd also like to see some comparison on performance. This project is pretty fast for many use cases and we've done performance bench-marking and improvements on it, although as far as I know, we haven't compared this library's performance to any others.
madhavgupta2011 commented 1 year ago

@stleary @johnjaylward let me revise that table and send it when I get time. Thank you.

henryx commented 1 year ago

Please, add the license in comparision table. JSON-Java is released as public domain, Jakarta JSON Api is released with Eclipse and GPL+ GNU Classpath Exception

lalithabourishetty-commits commented 11 months ago

@stleary difference between org.json and javax.json already discussed in the previous post, anything else i can do here as a beginner

stleary commented 11 months ago

@lalithabourishetty-commits Please create a file called library-comparison.md in the docs directory and populate it with the contents of the post by @madhavgupta2011 . Incorporate updates from the posts by @Chealer, @johnjaylward, and @henryx. If you want to include any other libraries in the comparison, that would be great too. You should use GitHub markdown to mark up the text.

lalithabourishetty-commits commented 11 months ago

@stleary while trying to clone forked repo facing access issue, any permission do i need ?

lalithabourishetty-commits commented 11 months ago

just ignore above

Simulant87 commented 6 months ago

@stleary :

Generally considered slower? Really?

I found this JSON library benchmark comparison project: https://github.com/fabienrenaud/java-json-benchmark

The results in the of the benchmark are displayed as graphs in the Readme. Based on this benchmark org.json is at the lower end, compared to other optimised libraries.