Pregunta

Right now the json gets serialized like so:

{ MyClassList : [{
  {
   ...
  },

  {
   ...
  },
}]

class:

public MyClass{
  properties here ...
}

java object being serialized:

new ArrayList<MyClass> list = new ArrayList<MyClass>();
list.add(new MyClass());

How do I change "MyClassList" to another custom name? for example, how do I change it to "MyClassAbc"?

¿Fue útil?

Solución

I think you want make this

You can use @JsonProperty("MyClassAbc")

So you can rename the "RootName"

class MyInterfaceList{
      @JsonProperty("MyClassAbc")
      private List<MyClass> list;

      public List<MyClass> getList(){
          return list;
      }
      public void setList(List<MyClass> list){
          this.list =list;
      }
   }
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top