HashMap<String, Object> hashMap = new HashMap<>();
JSONObject jsonObject = JSONObject.parseObject(userMapString);
int total = (int) jsonObject.get("total");
JSONArray rowsArray = jsonObject.getJSONArray("rows");
for(int i=0;i<rowsArray.size();i++){
User user1 = new User();
JSONObject rowsObj = (JSONObject) rowsArray.get(i);
user1.setUserId(rowsObj.getString("userId"));
user1.setUserName(rowsObj.getString("userName"));
user1.setPassword(rowsObj.getString("password"));
user1.setBigName(rowsObj.getString("bigName"));
user1.setEmail(rowsObj.getString("email"));
user1.setPhone(rowsObj.getString("phone"));
user1.setSex(rowsObj.getString("sex"));
user1.setCreateTime(rowsObj.getString("createTime"));
user1.setStates(rowsObj.getString("states"));
hashMap.put("rows",user1);
}
hashMap.put("total",total);
String字符串转hashMap
最新推荐文章于 2024-07-14 03:39:38 发布