Skip to content
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

Added failing test for JsonIgnoreType with MixIn #380

Merged
merged 1 commit into from
Jan 7, 2014
Merged

Added failing test for JsonIgnoreType with MixIn #380

merged 1 commit into from
Jan 7, 2014

Conversation

marceloverdijk
Copy link

As discussed on the user group http://jackson-users.ning.com/forum/topics/serializing-with-ignorejsontype-in-mixin-not-working

@JsonIgnoreType is not woorking with MixIns.

cowtowncoder added a commit that referenced this pull request Jan 7, 2014
Added failing test for JsonIgnoreType with MixIn
@cowtowncoder cowtowncoder merged commit 9bff69f into FasterXML:master Jan 7, 2014
@cowtowncoder
Copy link
Member

Thank you! I will try to figure out what is going on here.

@cowtowncoder
Copy link
Member

Ah ok. I can see the misunderstanding here -- meaning of @JsonIgnoreType is not quite what you expect. It does not change the default visibility of properties; rather, it makes any properties declared with that type to be ignored.
I modified the test, moved it in TestIgnoredTypes, and it works as intended.

What you may want to use instead, if you want to avoid including public properties by default is to use @JsonAutoDetect and set visibility to Visibility.NONE for all accessors (or at least getters and setters); this way only explicitly annotated properties are automatically detected.
An alternative is ObjectMapper.setVisibility() which can be used to define the baseline for all types; this is the most commonly used way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants