[jackson-user] class level JsonSerializable vs Method level

2018-12-20 Thread matt Smith
I encountered a case where class level JsonSerializable annotation does not require registration with Simple Module but method level does . Here is the example I trie

Re: [jackson-user] class level JsonSerializable vs Method level

2018-12-20 Thread Tatu Saloranta
On Thu, Dec 20, 2018 at 11:22 AM matt Smith wrote: > > I encountered a case where class level JsonSerializable annotation does not > require registration with Simple Module but method level does. Hmmh. This seems odd, let's see. > Here is the example I tried > > @JsonSerialize(using = ItemRowS

Re: [jackson-user] class level JsonSerializable vs Method level

2018-12-21 Thread matt Smith
so I have made this wrapper and annotated getter with @JsonSerialize. however, I do not see it being applied. what is wrong here? public class Wrapper { private Map foo; public Wrapper(Map fooz) { foo = new HashMap<>(fooz); } @JsonSerialize( contentUsing = ItemRowSer

Re: [jackson-user] class level JsonSerializable vs Method level

2018-12-21 Thread Tatu Saloranta
On Fri, Dec 21, 2018 at 12:06 AM matt Smith wrote: > > so I have made this wrapper and annotated getter with @JsonSerialize. > however, I do not see it being applied. what is wrong here? That looks like it should work. If not, a unit test & issue would make sense. -+ Tatu +- > > public class W

Re: [jackson-user] class level JsonSerializable vs Method level

2018-12-21 Thread matt Smith
even moving annotation to the field did not work. Note I have annotated class ItemRow class which ofcourse i can't since it is part of legacy code. On Friday, December 21, 2018 at 12:49:21 PM UTC-8, Tatu Saloranta wrote: > > On Fri, Dec 21, 2018 at 12:06 AM matt Smith > wrote: > > > > so I hav

Re: [jackson-user] class level JsonSerializable vs Method level

2018-12-21 Thread matt Smith
In the above case, I called `mapper.writeValueAsString(wrapper.getFoo());` I changed to the following (moved to annotation to the field level). when I write using `mapper.writeValueAsString(wrapper)`, I see the expected serialization applied. However, extra node "foo" is added at root. is there

Re: [jackson-user] class level JsonSerializable vs Method level

2018-12-24 Thread Tatu Saloranta
On Fri, Dec 21, 2018 at 1:52 PM matt Smith wrote: > > even moving annotation to the field did not work. > Note I have annotated class ItemRow class which ofcourse i can't since it is > part of legacy code. Except that you should be able to do that with mix-in annotations. See for example https:

Re: [jackson-user] class level JsonSerializable vs Method level

2018-12-24 Thread Tatu Saloranta
On Fri, Dec 21, 2018 at 2:30 PM matt Smith wrote: > > In the above case, I called `mapper.writeValueAsString(wrapper.getFoo());` > > I changed to the following (moved to annotation to the field level). when I > write using `mapper.writeValueAsString(wrapper)`, I see the expected > serialization

Re: [jackson-user] class level JsonSerializable vs Method level

2019-01-02 Thread matt Smith
I just added @JsonAnyGetter to the wrapper class and now when I write mapper.writeValueAsString(wrapper), it gives the expected output. I don't understand why but it just works! @JsonAnyGetter @JsonSerialize(contentUsing = ItemRowSerializer.class) private Map foo; On Monday, Decem

Re: [jackson-user] class level JsonSerializable vs Method level

2019-01-02 Thread Tatu Saloranta
On Wed, Jan 2, 2019 at 4:09 PM matt Smith wrote: > I just added @JsonAnyGetter to the wrapper class and now when I write > mapper.writeValueAsString(wrapper), it gives the expected output. I don't > understand why but it just works! > > @JsonAnyGetter > @JsonSerialize(contentUsing = Item