JAVA中json对象转JAVA对象
时间:2020-03-29 00:37:51
收藏:0
阅读:68
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);
原文:https://www.cnblogs.com/pxblog/p/12590079.html
评论(0)