Is there a way to modify the field of POJO with new property(like using MixIns or @JSONProperty
) and get the modified POJO back ? (A way to add/modify field of a POJO dynamically ?)
Like I have a class
class PojoA<T>{
private T data;//field to be modified as NewData
}
So, I tried with MixIns like
public interface PojoMixIn<T> {
@JsonProperty("NewData")
T getData();
}
Now to get the modified field, I use ObjectMapper
mapper.addMixInAnnotations(PojoA.class,PojoMixIn.class);
mapper.writerWithDefaultPrettyPrinter().writeValueAsString(pojoA);
The actual result is a String
, but can I be able to get the modified POJO?