1、map转换成实体类对象
Map<String, Object> map = new HashMap<String, Object>();
//map转换为string
String str = JSON.toJSONString(map);
//string转换为对象
Object obj=JSON.parseObject(str,clazz);
2、实体类对象转换成map
RealNameAuth realNameAuth = new RealNameAuth();
//对象转换成string
String str = JSON.toJSONString(realNameAuth);
//string转换成map
Map<String, Object> map = JSON.parseObject(str, new TypeReference<Map<String, Object>>() {});
3、map转json
Map<String, Object> map = new HashMap<String, Object>();
JSONObject json = new JSONObject(map);
5、json转map
JSONObject json = new JSONObject();
//强制转换
Map<String, Object> map = (Map<String, Object>)json;
6、string转json
String str = "{\"username\":\"dsad\",\"qwewqe\":\"123\"}"; JSONObject json = JSONObject.parseObject(str);
4、json转string
JSONObject json = new JSONObject();
json.toJSONString();