Do you think `@JsonAnySetter` would work here, attached to Map? It
would get all values that do not map to existing regular properties?
It wouldn't do anything for underscores but would allow easy collection.

Or, if you want to strip underscore, you could specify method instead

  @JsonAnySetter
  void addProperty(String name, String value) {
      // modify name, add to Map
   }


-+ Tatu +-


On Mon, Apr 9, 2018 at 2:17 PM,  <s...@zaius.com> wrote:
> Hello,
>
> I'm trying to figure out the best way to implement a deserializer for the
> following setup:
>
> class Model {
>   private String prop1;
>   private String prop2;
>   Map<String, String> userDefined;
> }
>
> json:
>
> {
>   "prop1": "prop one",
>   "prop2": "prop two",
>   "_prop3": "prop three",
>   "_prop4": "prop four"
> }
>
> The fields prefixed with an underscore represent dynamic fields that can't
> be known in advance.  My goal is to use the default deserializer and then
> map the props prefixed with underscores to entries in the Map.  Can someone
> point me in the right direction on a solution?  I'm hoping to avoid doing a
> manual deserialization and ride on the default serializer if possible.
>
> Thanks in advance,
> Sean
>
> --
> You received this message because you are subscribed to the Google Groups
> "jackson-user" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to jackson-user+unsubscr...@googlegroups.com.
> To post to this group, send email to jackson-user@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"jackson-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jackson-user+unsubscr...@googlegroups.com.
To post to this group, send email to jackson-user@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to