问题描述
我遵循了 https://github.com/joelittlejohn/jsonschema2pojo/pull/310,但不确定如何在我的 json 架构中使用“deserializationClassproperty”...
这是我所拥有的
vehicle.json
{
"type": "object","id": "#Vehicle","additionalProperties": false,"javaType": "Vehicle",**"deserializationClassproperty" : "Car.class,Truck.class"**,"properties": {
"color": {
"type": "string"
}
}
}
car.json
{
"type": "object","id": "#Car","javaType": "Car","extends": {
"type": "object","existingJavaType": "Vehicle"
}
}
truck.json
{
"type": "object","id": "#Truck","javaType": "Truck","existingJavaType": "Vehicle"
}
}
inventoryitem.json
{
"type": "object","id": "#InventoryItem","javaType": "InventoryItem","properties": {
"vehicle": {
"#ref": "vehicle.json"
}
}
}
这是我尝试使用 XmlMapper 解组的输入
<InventoryItem><Vehicle xis:type="ns2:car"/></InventoryItem>
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS,include = JsonTypeInfo.As.PROPERTY,property = "Car.class,Truck.class")
public class Vehicle
但我需要按如下所示生成才能使其正常工作 我需要通过json模式生成以下内容
@JsonTypeInfo(use = JsonTypeInfo.Id.NAME,include = JsonTypeInfo.As.EXISTING_PROPERTY,property = "type")
@JsonSubTypes ({
@JsonSubTypes.Type(value = Truck.class,name = "truck"),@JsonSubTypes.Type(value = Car.class,name = "car")
})
public class Vehicle
还有如何忽略命名空间“ns2:car”
感谢您的时间
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)