Deserialize JSON in Java by inferring/embedding object type -
i serializing map<string, object>
json using jackson.
later when deserialize it, objects not of primitive type converted linkedhashmap
's instead of class belonged to.
is there way deserialize json map nested objects of correct type?
use constructcollectiontype of typefactory arraylist collectionclass & pojo class second argument , read "list" value using objectmapper. this:
list<t> list; objectmapper om = new objectmapper(); typefactory t = typefactory.defaultinstance(); list = om.readvalue(json, t.constructcollectiontype(arraylist.class,pojo_clazz));
hope helps!
Comments
Post a Comment