boonproject/boon

Problem with Generics types

Opened this issue · 0 comments

I have a classic use case of converting a map to JSON. The only catch here is the Map's value is instance of sub classses of an abstract class. Refer to following code:

public Map<String, JsonAbstractClassB> jsonMap;

where JsonAbstractClassB has two different sub classes JsonClassC and JsonClassD.

While setting the object of class C and class D and serializing works perfectly fine. When I deserialize a json back. All I get is instance of JsonAbstractClassB. Boon does not return me the instance of JsonClassC and JsonClassD.

I was referring to the example https://github.com/boonproject/boon/wiki/Boon-JSON-in-five-minutes#subclasses-interfaces-and-abstract-classes

and could see that if the object of abstract classes and sub classes are not wrapped in a collection, they work perfectly fine during deserialization but not when wrapped in collection.

Any help is highly appreciated.