[jackson-user] Custom Deserializer

2018-04-09 Thread sean
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.


Re: [jackson-user] Custom Deserializer

2018-04-09 Thread sean
That worked.  Thanks for the suggestion Tatu.

On Monday, April 9, 2018 at 6:47:15 PM UTC-4, Tatu Saloranta wrote:
>
> 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,  <se...@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...@googlegroups.com . 
> > To post to this group, send email to jackso...@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.


Re: [jackson-user] Windows CentOS differences

2018-08-08 Thread Sean Dawson
Oh ok - thanks so much for the info and that suggestion. Will check it out.


On Wed, Aug 8, 2018 at 2:55 AM, Tatu Saloranta  wrote:

>
>
> On Wed, Aug 8, 2018 at 6:52 AM  wrote:
>
>>
>> Hello, we have a web app that sits in Tomcat and uses RestEasy
>> 3.0.16.Final and Jackson 2.5.2. It's built once, using maven, and then
>> deployed pretty much the same to a Windows 7 and a CentOS 7.2 machines.
>>
>> Just in the last week, we've started to get ProcessingException errors on
>> a couple of our dtos...
>>
>> com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:
>> Unrecognized field "date" (class ...), not marked as ignorable (0 known
>> properties: ])
>>  at [Source: java.io.BufferedInputStream@44daddab; line: 1, column: 52]
>> (through reference chain: ...["date"])
>>
>> So for one of the dto's, I had to add 3 variables into
>> @JsonIgnoreProperties and for the other, I had to add 
>> @JsonAutoDetect(fieldVisibility
>> = JsonAutoDetect.Visibility.ANY).
>>
>> I don't know why this is. I can't think of anything that's changed in
>> this area recently. Or why it happens only on Linux (all the required
>> libraries are included on both, and they are exactly the same).
>>
>> Could it be a JDK issue? Some difference in configuration of another
>> component like RestEasy or Hibernate ?
>>
>>
> I do not know what specifically could cause this, but I would first
> consider upgrading at least to latest 2.5.x patch version (2.5.5).
> As to root cause I would probably try to thoroughly check that you do not
> somehow have multiple versions of Jackson-databind jar; if multiple exist,
> loading order is arbitrary and could well be OS dependant. And typically
> nothing good comes out of conflicting versions anyway; it is a common cause
> for strange errors. So maybe that could be happening here?
>
> -+ Tatu +-
>
>
>> Thanks.
>>
>> --
>> 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 a topic in the
> Google Groups "jackson-user" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/
> topic/jackson-user/8CEA11OKlxE/unsubscribe.
> To unsubscribe from this group and all its topics, 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.