我有一个这样的东西作为一个JSON,并需要将其转换为杰克逊的Java用户实例。杰克逊序列化与类型混合?
"userid" : "1",
"myMixes" : [ {
"data" : {
"id" : 1,
"ref": "my-Object-instance"
},
"type" : "object"
}, {
"data" : [ [ 0, 1], [ 1, 2 ] ],
"type" : "list"
}]
我有这个在我的课“用户”:
// jackson should use this, if type="list"
@JsonProperty("data")
public List<List<Integer>> data_list = new ArrayList<>();
// jackson should use this, if type="object"
@JsonProperty("data")
public Data data_object;
@JsonProperty("id")
public String id;
// if type = "object", then jackson should convert json-data-property to Java-Data-Instance
// if type = "list",then jackson should convert json-data-property to List<List<Integer>> data
@JsonProperty("type")
public String type;
我怎么能告诉杰克逊生成JSON数据属性的数据,例如,如果JSON的类型 - 价值属性称为“对象”,并且如果json-type-property的值被称为“list”,则生成List-Instance。
我的解决方案和你的解决方案有什么不同?你的速度更快吗? – nimo23