-
Notifications
You must be signed in to change notification settings - Fork 5
Support using @Json.Ignore on a type #366
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
Conversation
Manually setting the ignore on each field get's old after a while
I think we should be good for 3.4 after this |
This does not make sense to me. Putting What is the use case? What does this mean? |
jsonb-generator/src/test/java/io/avaje/jsonb/generator/models/valid/SerializerTest.java
Outdated
Show resolved
Hide resolved
jsonb-generator/src/test/java/io/avaje/jsonb/generator/models/valid/ignore/IgnoredClass.java
Show resolved
Hide resolved
jsonb-generator/src/main/java/io/avaje/jsonb/generator/PropertyIgnoreReader.java
Outdated
Show resolved
Hide resolved
Remember that you can control both serialization and deserialization with ignore |
It's basically like Jacksons's |
This is the part that was left out of the description, the use case for doing this. I've added that into the description. |
So what is the actual use case? There is a type and it should not support deserialisation at all? I'm not sure the current solution is great in that when deserialisation is done it will produce an a type with an empty result - and this seems invalid or un-useful. It more seems that if we turn off deserialisation altogether than it shouldn't be used at all? So I'm wondering what is the actual use case, why do we think an "empty result" is valid? |
With this you can change the default behavior for a specific class, it can be overridden by the property annotation to a field or by adding the ignore annotation to that field and flipping the boolean |
See the tests, you can still selectively enable the properties you want. |
Hmm, it's not as ergonomic as I had hoped. I'll get back to this later |
Manually setting the ignore on each field gets old after a while
Allows putting
@Json.Ignore(serialize=true)
on the type such that all properties are not included in deserialisation (or the opposite via@Json.Ignore(deserialize=true)
.