0

The code snippet goes like this:

Request {
//other properties
RequestList list;

//setters and geters
}

RequestList extents TypeSafeList {

add(Parent p) {
}

}

TypeSafeList extends ArrayList {

}

Parent {}

Child extends Parent {
}

While converting into json from the object is simple, but while converting it back to object, I get the object of Request, but the property list in Request class instead of having the objects of Child has linkedhashmap.

I am assuming this is because, in RequestList class, I have mentioned the parent class as method arguement, and while deserializing, it doesn't know which concrete class object it is referring to.

Any help would be appreciated.

Ankit garg
  • 71
  • 6
  • `ArrayList` is a raw type. Use `ArrayList`. – shmosel Jan 08 '18 at 03:49
  • But, if parent has multiple childs, then while deserialization, how would jackson api know that, which child object it has to create. – Ankit garg Jan 08 '18 at 07:07
  • Jackson supports polymorphism deserialization, but you'll likely have to encode additional info into the JSON. Here's an introduction: https://github.com/FasterXML/jackson-docs/wiki/JacksonPolymorphicDeserialization – shmosel Jan 08 '18 at 07:16
  • Thanks a lot for your help. enabledefaulttypeing() worked for me. – Ankit garg Jan 10 '18 at 04:58

0 Answers0