pass instances of extended class to the controller that accepts base type

Viewed 13

I have a Spring Rest API that accepts a list of Node.

Map<String,Object> createFlow(@RequestBody List<Node> flowDTO)

And I have some type information

class Node{
   String id;
}
class RuleNode extends Node{
   Map<String, Object> rules
}
class DataNode extends Node{
   String dataName
}

How can I to pass instances of DataNode and RuleNode to the rest API, so that the they can be decoded back in the controller correctly?

0 Answers
Related