public class MainBean
{
private List<UserBean> user = new ArrayList<UserBean>();
// getter/ setter
}
public class UserBean
{
private String actor; // this for "actor": "ashok"
private Map<String, String> actorMap; // this for second case
private List<String> actors; // this for third case
@JsonAnySetter
public void set(String name, Object value)
{
if (value instanceof String)
{
actor = (String) value;
}
else if (value instanceof Map)
{
actorMap = (Map<String, String>) value;
}
else if (value instanceof List)
{
actors = (List<String>) value;
}
}
}
第二种情况,您可以创建带有两个字符串字段的简单类,name
然后mail
在其上创建新实例if (value instanceof Map)