Java 从 Redis中取出的Json字符串 带斜杠的问题解决方案
Java 从 Redis中取出的Json字符串 带斜杠的问题:
{
"code": 200,
"message": "成功",
"data": "{\"regionNames\":\"北冥县\",\"regionIds\":\"105\",\"enabled\":true,\"dataPermissions\":[],\"postIds\":\"34\",\"id\":103,\"deptIds\":\"69\",\"menus\":[],\"email\":\"1034214262@qq.com\",\"sysRoles\":[{\"code\":\"1\",\"createTime\":\"2020-07-13 15:56:04\",\"name\":\"应急处置应急资源保障\",\"memo\":\"应急资源保障全部权限\",\"editTime\":\"2020-07-13 16:32:28\",\"id\":36,\"status\":1},{\"code\":\"1\",\"createTime\":\"2020-11-23 15:17:48\",\"name\":\"公众出行管理员\",\"memo\":\"\",\"id\":42,\"status\":1},{\"code\":\"1\",\"createTime\":\"2020-07-07 10:13:14\",\"name\":\"机电运维角色\",\"memo\":\"机电运维全部权限\",\"editTime\":\"2020-07-20 15:04:48\",\"id\":27,\"status\":1}],\"accountNonLocked\":true,\"postNames\":\"应急专家\",\"sex\":2,\"credentialsNonExpired\":true,\"sysPermissions\":[],\"dataSysRoles\":[{\"code\":\"1\",\"createTime\":\"2020-07-13 10:42:12\",\"name\":\"信息部+A区域\",\"editUser\":1,\"memo\":\"信息部+A区域数据权限\",\"createUser\":1,\"editTime\":\"2020-07-13 10:42:12\",\"id\":127,\"status\":1}],\"deptNames\":\"公路保障部\",\"phone\":\"13888374038\",\"name\":\"机电智慧运维管理员\",\"accountNonExpired\":true,\"username\":\"jdzhyw\"}"
}
解决方案:alibaba.fastjson
//直接转对象,去除反斜杠
JSONObject jsonObject= (JSONObject) JSON.parse(str);