我希望将以下jsonArray直接反序列化为Map对象
[ { “userId": 1234, "userName": “abc”, "someList": [ 234, 12, 126, 137 ] },
{ "userId": 423, "userName": “mac”, "someList": [ 234, 2235, 226, 227 ] } ]
进入Map<UserInfo, Set<Long>>
userId和userName放入UserInfo类,将someList放入Set<Long>
。
userinfo类如下
public class UserInfo {
private int userId;
private String userName;
private String preference;
public UserInfo(@JsonProperty("userId")int userId, @JsonProperty("userName")String userName) {
super();
this.userId = userId;
this.userName = userName;
}
public UserInfo() {
}
public int getUserId() {
return userId;
}
public void setUserId(int userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPreference() {
return preference;
}
public void setPreference(String preference) {
this.preference = preference;
}
@Override
public String toString() {
return "UserInfo [userId=" + userId + ", userName=" + userName
+ ", preference=" + preference + "]";
}
}