import com.alibaba.fastjson.JSON;
import org.json.JSONObject;
public CustomerMessage getCustomerMessage (JSONObject json) throws ParseException {
CustomerMessage message = new CustomerMessage();
message.setId(json.getLong("id"));
message.setComments(json.getString("comments"));
message.setOperator(json.getString("operator"));
message.setStatus(json.getString("status"));
String time = json.getString("createTime");
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
message.setCreateTime(sdf.parse(time));
message.setContactNumber(json.getString("contactNumber"));
message.setContactPerson(json.getString("contactPerson"));
message.setContent(json.getString("content"));
message.setFeedbackType(json.getString("feedbackType"));
message.setOrgId(json.getString("orgId"));
message.setUserId(json.getString("userId"));
message.setUserType(json.getString("userType"));
return message;
}
public PageInfo<CustomerMessage> getPageInfo (JSONObject json) {
PageInfo<CustomerMessage> info = new PageInfo<>();
info.setPageNum(json.getInt("pageNum"));
info.setPageSize(json.getInt("pageSize"));
info.setTotal(json.getLong("total"));
String str = json.getJSONArray("list").toString();
List<CustomerMessage> list = JSON.parseArray(str, CustomerMessage.class);
info.setList(list);
return info;
}
Json对象转java对象,json数组转list
最新推荐文章于 2024-06-29 02:59:21 发布