json格式
{userId:'1',message:'2',create_time:'2020-03-28 20:58:11',create_date:'2020-03-28'}
JAVA对象
ChatDTO.java
public class ChatDTO {
private String userId;
private String message;
private String createDate;
private String createTime;
}
......
get set 方法
JSONObject object = JSONObject.fromObject(json); //先转成json对象
ChatDTO chatDTO = (ChatDTO) JSONObject.toBean(object, ChatDTO.class);