0

My question is similar to the one found in this question but I am not looking to hide fields of a nested object. I just want to hide the name of a nested object in a wrapper class.

My class structure is something like

public class Outer {
    Inner obj;
}

public class Inner {
    String a;
    String b;
}

When serializing an instance of Outer I would like it to appear the same as a serialization of Inner. Like:

{
   "a":"abc",
   "b":"xyz"
}

and not

{
    "obj" : {
        "a":"abc",
        "b":"xyz"
    }
}

Is there an annotation I can use, or do I need to implement my own TypeAdapter similar to this question?

Aposhian
  • 801
  • 1
  • 10
  • 27

0 Answers0