I have code like this:
import org.codehaus.jackson.map.*;
public class MyPojo {
int id;
public int getId()
{ return this.id; }
public void setId(int id)
{ this.id = id; }
public static void main(String[] args) throws Exception {
MyPojo mp = new MyPojo();
mp.setId(4);
ObjectMapper mapper = new ObjectMapper();
mapper.configure(SerializationConfig.Feature.WRAP_ROOT_VALUE, true);
System.out.println(mapper.writeValueAsString(mp));
}
}
It works expected:
{"MyPojo":{"id":4}}
But I want to customize that name. I am not able to mark MyPojo
with @JsonTypeInfo
becausee i take this class from library.
Is there way to do it in jackson?