-
Notifications
You must be signed in to change notification settings - Fork 61
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
#153 implemented abstract JsonObject and JsonArray #227
base: master
Are you sure you want to change the base?
Conversation
@m0mus You said you are skeptical of the idea and that the idea of the library is for concrete classes to be constructed via the But the scope of the The 2 classes in this PR are abstract (basically interfaces as well) and provider-agnostic as well. If you ask me, even the class So the point is that, if the API does not offer class cc: @m-reza-rahman |
Signed-off-by: amihaiemil <[email protected]>
@m0mus @m-reza-rahman I've also made an Eclipse Account and signed the ECA. Now I get an error message saying:
I have reset my commit and redone it with the |
Signed-off-by: amihaiemil <[email protected]>
Signed-off-by: amihaiemil <[email protected]>
Signed-off-by: amihaiemil <[email protected]>
I am still skeptical.
|
@m0mus I'm answering punctually
JsonObject and JsonArray are interfaces. How they are implemented is not important.
But this is not true. Simply adding these 2 abstract classes does not mean other implementations of JsonObject or JsonArray are forced to extend them. Why do you think JSON-P providers would be obliged to use these classes?
Same as above, these 2 classes have nothing to do with other implementations of JsonObject. And again, adding these classes to a provider's implementation doesn't make sense since they are provider agnostic -- they work only with interfaces from the API, nothing concrete.
That's exactly the issue: Users are provided only with methods, which they will use as utilities in other static methods throughout their code. As the It's not such an uncommon usecase. The point is actually about extension. Extension by composition, not inheritance. And in order to create/extend my own JsonObject or JsonArray I need to implement that interface... and I implement it based on an existing JsonObject or JsonArray. Another usecase: in order to avoid Swagger (it was too big for my needs), I made my JAX-RS classes implement JsonObject and in their constructor, I initialized the key/value pairs with the JAX-RS endpoints offered by that class. So, I would simply return that object to the user which was automatically rendered as JSON. |
@m0mus Maybe the name of these 2 classes is wrong. Maybe But I can't think of a better name. Ideas? :D |
@m0mus The common/uncommon argument is actually irrelevant if you ask me. As long as functionalities respect given interfaces and are provider-agnostic, I don't see any reason why they should not be added. This is the standard JSON api for Java, but its authors should not impose their way of thinking on users. The bigger the variety of tools the users are provided with, the better, I would say :D |
@m0mus Another option would be to add these 2 classes in a package named |
Design cohesion of an API is very important. That's why it is important to work closely and as best as is possible align with existing design thinking. Unless a substantial portion of existing users and committers feel otherwise, I am inclined to respect Dmitry's opinion on this. Let us try to see if we can collaborate to make a compelling case for this enhancement. Reza Rahman Please note views expressed here are my own as an individual community member and do not reflect the views of my employer. |
@m0mus @m-reza-rahman This functionality can also be implemented with interfaces and default methods. We would have interfaces What do you think? Would it be more suitable, would you accept the PR with this implementation? |
PR for #153.
Implemented AbstractJsonObject and AbstractJsonArray. These classes are very useful for users who want to implement their own JsonObject or JsonArray objects.
See JavaDocs for examples of usage.
These classes should be provided by the API since they are provider-agnostic.