我正在使用 Java 1.8 和 FasterXML。
假设您有一个由 JSON 数组组成的数组列表:
[
{
"id": "8",
"musician": {
"band": {
"bandId": "104"
},
"genre": {
"type": "country",
"typeId": 123
},
"musician": {
"id": "87"
}
}
},
{
"id": "9",
"musician": {
"band": {
"bandId": "104"
},
"genre": {
"type": "country",
"typeId": 123
},
"musician": {
"id": "88"
}
}
}
]
public class Musician {
private int id;
private Band band;
private Genre genre;
// How to marshal this?
private Musician musician;
}
public class Band {
private bandId;
}
public class Genre {
private String type;
private String typeId;
}
如果您需要从类中编组相同类型(即 ),如何设置顶级Musician
类?
有注释可以使用吗?
应该,我只是将内部的 Musician 类命名为别的吗?