JSON,JSONOBJECT,JSONARRAY 互转

1.jsonobject转对象:JSONObject json = (JSONObject) JSONObject.toJSON(obj);

                                  PolicyBean vo = JSONObject.toJavaObject(json, PolicyBean.class);

2.List<ConfigEntityVO> attrLists = JSON.parseArray(vo.getAttrs(), ConfigEntityVO.class);

3.JSONObject attrLists = JSON.parseObject(vo.getAttr(), JSONObject.class) ;

4.map转对象 :

Map<String, Object> configUserInfo = null;
configUserInfo = (Map<String, Object>) object.get("userinfo");
userinfo = JSONObject.parseObject(JSONObject.toJSONString(configUserInfo), UserLoginDTO.class);

posted @ 2020-10-20 09:37  JLCUI  阅读(366)  评论(0编辑  收藏  举报