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

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

Open
Chealer opened this issue Oct 27, 2022 · 10 comments
Open

Comments

@Chealer
Copy link

Chealer commented Oct 27, 2022

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

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

stleary commented Jul 10, 2023

@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
Copy link
Contributor

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

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

@henryx
Copy link

henryx commented Aug 18, 2023

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

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

@stleary
Copy link
Owner

stleary commented Oct 4, 2023

@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

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

@lalithabourishetty-commits

just ignore above

@Simulant87
Copy link
Contributor

@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.

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

7 participants