1

I receive a json list of objects. Let's call it list of some class MyClass.class. So I can easy deserialize it to List<MyClass>. But I want to add a wrapper class, for example:

class MyWrapper {

    private List<MyClass> items;

    //Getter & Setter

}

And I want to deserialize the following json:

[
    {
        ...
    },
    {
        ...
    }
]

to MyWrapper.class. How can I do it using jackson annotations ?

Nikita
  • 1,465
  • 3
  • 15
  • 17

1 Answers1

0

your wrapper class will be serialized to something like this.

{
   "items":[
       {...},
       {...}
    ]
}

which is not same as your input. If you can access JSON object before serialization, you can modify input.

String modifiedJson = "{\"items\":" + input + "}";
lucid
  • 2,722
  • 1
  • 12
  • 24