2
我怎麼能得到一個簡單的JSON結構這樣JAXB添加枚舉爲平面結構
{
"id": 9901,
"name": "Reader",
"value": true
}
與JAXB註釋和代碼? (的UserInfo應該包含在同一層級枚舉字段)
@XmlRootElement
public class UserInfo
{
private UserLevel level;
@XmlElement (name = "value")
private boolean allowed;
}
public enum UserLevel
{
READER ("Reader", 9901),
TESTER ("Tester", 9903);
private final String name;
private final int id;
private UserLevel(String name, int id)
{
this.name = name;
this.id = id;
}
get...()
}
好主意,謝謝! –