(1) java的List对象转乘Array
List<String> list = new ArrayList<String>();
String[] array= list .toArray(new String[list .size()]);
(2)JSON的string 转换成obj
String result = “{id:‘11’,name:‘张三’}”;
//转成JSON的obj
JSONObject obj = JSON.parseObject(result);
//转成java的实体(如 ImageQMsg 实体类)
ImageQMsg imageQMsgObj = JSON.parseObject(result , ImageQMsg.class);
(3)JSON的string 转换成Array(LIST)
String result = “{id:‘11’,name:‘张三’}”;
//转成JSON的obj
JSONArray array = JSON.parseArray(result);
//转成java的实体(如 AttendanceDingding实体类)
List<AttendanceDingding> attendanceList = JSON.parseArray(result , AttendanceDingding.class);
(4)字符串转换成日期格式
String topicCompanyJsonStr = JSON.toJSONStringWithDateFormat(taskViewList,"yyyy-MM-dd");
说明:接收到的字符串 转换成实体类用:JSON.parseObject()
转换成List:JSON.parseArray()