Closed jansupol closed 6 years ago
@bravehorsie Commented This strategy will eliminate usage of getters,setters by default. In case private field has public setter / getter it won't be used. What is the motivation for doing so?
@m0mus Commented I don't think it should be a part of the standard. We give users an ability to change visibility strategy and it's up to implementation which strategies will be provided out of the box. I think it's a good idea if we add it to Yasson for convenience.
@steappe Commented I'm also using this private field strategy. The motivation is as follows:
In short, I generally prefer a field approach over a (get/set) property approach because then I don't have to change the methods of my domain model to suit the constraints of a serialization / deserialization framework. The same applies when I use JPA for instance.
Adding a private field strategy to Yasson for convenience would be great.
@m0mus Commented This feature was added to Yasson: https://github.com/eclipse/yasson/pull/65
Closing this issue.
Currently only public class fields are serialized. Use "PrivateFieldVisibilityStrategy" per convention:
The strategy above should work out-of-the-box without any additional steps (JsonbConfig) required.