Custom serialization to nested JSON via annotation

19 views
Skip to first unread message

Wojciech Olech

unread,
Sep 16, 2019, 2:42:01 PM9/16/19
to jackson-user

Hi,


I'm looking for some easy convinient way using annotations for flat object serialization to neseted JSON, see example below:


class Abcde {

   String a;

   String b;

   String c;

   String d;

   String e;

}


to


{

  a:"a",

  b:"b",

  cde: {

     c:"c",

     de: {

        d:"d",

        e:"e"

     }

  }

}


I know that I can do it by implementing custom serializer, but somehow I hope that there is quick annotation for that, like: @JsonProperty("nested1/nested2/name")


Thanks

Wojciech Olech

unread,
Sep 16, 2019, 2:42:01 PM9/16/19
to jackson-user

Tatu Saloranta

unread,
Sep 16, 2019, 2:47:19 PM9/16/19
to jackson-user
At this point a custom serializer and deserializer would be needed.

There is an issue to add `@JsonWrapped`, which (if implemented) would
allow change in nesting (as an opposite of existing `@JsonUnwrapped`),
but that has not been implemented nor has there been any active work
to make that happen.

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