-
-
Notifications
You must be signed in to change notification settings - Fork 422
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
Initial implementation for JsonBindingService #515
Conversation
Also-By: Flavio Costa <flavio.costa.br@gmail.com> Signed-off-by: Kai Kreuzer <kai@openhab.org>
Many binding consuming JSON data from upstream API servers import and use the annotation com.google.gson.annotations.SerializedName to really clamp down the attribute naming. How would this work if the specific json binding is abstracted away? |
Signed-off-by: Kai Kreuzer <kai@openhab.org>
@flaviocosta-net Can you answer @hakan42's question? |
I am missing an answer of this question for months, too. See: eclipse-archived/smarthome#5884 (comment) |
@kaikreuzer, before getting to the topic here, I'd like to thank you for the effort you've put into ESH until now (while you still had the Herculean amount of spare time needed to lead that)! @hakan42 and @maggu2810, the idea was to consider this topic after the initial contribution was accepted (which never happened on the previous repository, largely because of the continuous issues I had with Travis or dependency resolution issues)... Right now, there is no support for customized naming in this wrapper implementation but I see it must be supported as the feature is used in several places - we just need to agree on the design so I can test and implement something. The reason why this JSON binding service even exists is because we failed to find a suitable implementation of the new JSON-B standard that does not rely on too many undesirable code dependencies. I think we may eventually remove this, and use JSON-B directly, but for now it may be useful as a first step to move away from Gson. The JSON-B of doing this is either on the field, or on the get/set methods:
Should we also have |
Correct me if I am wrong, but if we want to use JSON in the code base, we will develop and compile against With that in mind, I don't care if the annotation is named |
So we would first rely on an org.openhab....JsonProperty first and then at some future time just change the import at the top of the class? I must admit that I am partial to the SerializedName annotation, but this is my day-in-and-day-out work with Spring which trained my mind into a specific direction 😁 The important part is really that we can decouple the class property names in the java class from the names in the serialized data stream. |
@@ -0,0 +1,19 @@ | |||
This content is produced and maintained by the Eclipse SmartHome project. | |||
|
|||
* Project home: https://eclipse.org/smarthome/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update this to an openHAB NOTICE file.
@@ -0,0 +1,19 @@ | |||
This content is produced and maintained by the Eclipse SmartHome project. | |||
|
|||
* Project home: https://eclipse.org/smarthome/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update this to an openHAB NOTICE file.
Is that still being developed? |
I think this is waiting for a decision on #611 (comment)... |
Using official standards and to develop for APIs instead of specific implementation should always be preferred. I don't know if the time that has been invested and needs to be further invested (development - review - cycles) makes sense. So, how far are we from using a "official standard"? |
javax.json is the official way :D Everyone is using jackson or gson out there, without abstraction layer. I don't understand why OH needs one. |
Well, it is ready, but it causes (functional) conflicts with #611, which are not easy to overcome. If @flaviocosta-net is fine with it, I'd therefore suggest to close this PR despite all the effort that already went into this feature. |
Ported over from eclipse-archived/smarthome#5856
Also-By: Flavio Costa flavio.costa.br@gmail.com
Signed-off-by: Kai Kreuzer kai@openhab.org