在这个链接
我试图理解为什么我(可能)需要@JsonTypeName
子类(就像所有的'internet; sujests to put)如果它没有它就可以工作?
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "aType")
@JsonSubTypes(Array(
new Type(value = classOf[ModelA], name = "ModelA"),
new Type(value = classOf[ModelB], name = "ModelB")
))
class BaseModel(val modelName:String)
//@JsonTypeName("SomeModel") // Commented. Do I need this?
class ModelA(val a:String, val b:String, val c:String, commonData:String) extends BaseModel(commonData) {
def this() = this("default", "default", "default" ,"default")
}
//@JsonTypeName("SomeModel") // Commented. Do I need this?
class ModelB(val a:String, val b:String, val c:String, commonData:String) extends BaseModel(commonData) {
def this() = this("default", "default", "default" ,"default")
}