Customized handling of unknown properties.

14 views
Skip to first unread message

jmna...@gmail.com

unread,
May 7, 2019, 7:41:55 PM5/7/19
to jackson-user
Hi,

I believe I have quite specific question. Is there a path in which I could customize the Jackson deserializer in a way that for every unknown property it would populates object internal map with it's value?

Example: Simple Java POJO:

class SomeEntity {
  String attribute1;
  String attribute2;

  Map<String, Object> additionalAttributes;
}

I know that on high level Jackson allows me to either enable or disable failing on unknown properties through FAIL_ON_UNKNOWN_PROPERTIES option, though is there any extendable way to customize this behaviour?

Thanks in advance.

Tatu Saloranta

unread,
May 8, 2019, 3:02:53 PM5/8/19
to jackson-user
Yes, this is what `@JsonAnySetter` would do; add that to
`additionalAttributes` and that should work (for fields requires
jackson 2.8; earlier only 2-argument setter method could be
annotated).

-+ Tatu +-
Reply all
Reply to author
Forward
0 new messages