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

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -

Why does a .NET 4.0 program produce a system.unauthorizedAccess error on a Windows Server 2012 machine with .NET 4.5 installed? -