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

Configuration for jackson to ignore unknown properties by default #12684

Closed
leocwolter opened this issue Mar 29, 2018 · 10 comments
Closed

Configuration for jackson to ignore unknown properties by default #12684

leocwolter opened this issue Mar 29, 2018 · 10 comments
Labels
status: invalid An issue that we don't feel is valid

Comments

@leocwolter
Copy link

I would like to avoid adding the annotation @JsonIgnoreProperties(ignoreUnknown = true) on every class, is it possible to add a configuration for that purpose?

I was thinking of something like:

spring.jackson.default-property-ignore=ignore_unknown
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Mar 29, 2018
@philwebb
Copy link
Member

@leocwolter Can you use a Jackson2ObjectMapperBuilderCustomizer bean and call mixIn(Object.class, MixinAnnotations.class) to do this?

@philwebb philwebb added the status: waiting-for-feedback We need additional information before we can continue label Mar 29, 2018
@philwebb
Copy link
Member

Oh wait. I misread your initial comment. I think we set ignoreUnknown for unknown properties by default. Can you share a sample that shows what you're trying to do?

@philwebb
Copy link
Member

See #1237. We do have DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES defaulting to false already.

@philwebb philwebb added status: invalid An issue that we don't feel is valid and removed status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged labels Mar 29, 2018
@agogs
Copy link

agogs commented Oct 29, 2018

You can use spring.jackson.deserialization.fail-on-unknown-properties=false

@vfonic

This comment has been minimized.

@snicoll

This comment has been minimized.

@jlous
Copy link

jlous commented Jun 30, 2022

The spring default and spring override do not apply to the objectmapper Hibernate uses. Customising parsing for json columns in spring is still impenetrable magic.

@wilkinsona
Copy link
Member

Prior to Hibernate 6 (which is not yet supported), I don't think Hibernate uses Jackson. To double-check, I prepped Hibernate's 5.6.9 tag and found no occurrences of jackson.

If you think there's something that Spring Boot should be configuring with the main ObjectMapper, please open a new issue and we can take a look. We'll need to know exactly where that ObjectMapper is being used. A small sample that reproduces the problem you're facing is the ideal way to show us.

@jlous
Copy link

jlous commented Jun 30, 2022

Ok. I just saw a way of making hibernate use spring's objectmapper (https://stackoverflow.com/questions/66656772/use-jackson-objectmapper-configured-by-spring-boot-in-hibernate) so I assumed it used a similar one by default.

I do wish there was a simple way to achieve this with regular spring configs

@wilkinsona
Copy link
Member

The person who asked that question is using Hibernate Types, a library that builds on top of Hibernate. Boot knows nothing about it so it isn't something that we can configure automatically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

8 participants