Skip to content

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

Closed
wants to merge 5 commits into from
Closed

Conversation

SentryMan
Copy link
Collaborator

@SentryMan SentryMan commented Apr 24, 2025

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

Manually setting the ignore on each field get's old after a while
@SentryMan SentryMan added the enhancement New feature or request label Apr 24, 2025
@SentryMan SentryMan added this to the 3.4 milestone Apr 24, 2025
@SentryMan SentryMan self-assigned this Apr 24, 2025
@SentryMan SentryMan requested a review from rbygrave April 24, 2025 02:24
@SentryMan SentryMan enabled auto-merge April 24, 2025 02:27
@SentryMan
Copy link
Collaborator Author

I think we should be good for 3.4 after this

@rbygrave
Copy link
Contributor

This does not make sense to me. Putting @Json.Ignore on the type would be the same as not having any @Json ... unless it means something else??

What is the use case? What does this mean?

@SentryMan
Copy link
Collaborator Author

Putting @Json.Ignore on the type would be the same as not having any @JSON

Remember that you can control both serialization and deserialization with ignore

@SentryMan SentryMan requested a review from rbygrave April 24, 2025 15:55
@SentryMan
Copy link
Collaborator Author

SentryMan commented Apr 24, 2025

What is the use case? What does this mean?

It's basically like Jacksons's @JsonIgnoreProperties(allowGetters=true/false, allowSetters=true/false)

@rbygrave
Copy link
Contributor

Remember that you can control both serialization and deserialization with ignore

This is the part that was left out of the description, the use case for doing this. I've added that into the description.

@rbygrave rbygrave changed the title Use Ignore on a type Support using @Json.Ignore on a type Apr 27, 2025
@rbygrave
Copy link
Contributor

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?

@SentryMan
Copy link
Collaborator Author

SentryMan commented Apr 27, 2025

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

@SentryMan
Copy link
Collaborator Author

See the tests, you can still selectively enable the properties you want.

@SentryMan
Copy link
Collaborator Author

Hmm, it's not as ergonomic as I had hoped. I'll get back to this later

@SentryMan SentryMan closed this Apr 27, 2025
auto-merge was automatically disabled April 27, 2025 21:55

Pull request was closed

@SentryMan SentryMan removed this from the 3.4 milestone Apr 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants