Is it possible to serialize/deserialize Map
where type of object (mapped value) would be determined by its key.
{
\"nu
Yes, it could be done.
Have another structure that contains a pair of Map<String, Class>
and link the key name of the first structure (Map<String, Object>
) to the second one.
For example
Map map = new HashMap<String, Object>();`
map.put("desc", "something really important");
Map deser = new HashMap<String, Class>();
deser.put("desc", StringDeserializer.class);
You could also use a deser<String, String>
, where the value would be the class name, then you just do a class loading by name http://www.tutorialspoint.com/java/lang/class_forname_loader.htm
Yes, it's possible. I would recommend you to try jsonschema2pojo. Just paste you JSON
and select source type JSON
.