fastjson fastuse
2020-02-27 本文已影响0人
YYYYYY25
-
OBJ -> String
String str = JSONObject.toJSONString(obj); -
JSONObject -> String
String str = JSONObject.toJSONString(jobj);
String str = jobj.toJSONString(); -
String -> JSONObject
JSONObject jobj = JSONObject.parseObject(str); -
String -> OBJ
Teacher teacher = JSONObject.parseObject(str, Teacher.class)
Teacher teacher = JSONObject.parseObject(str, new TypeReference<Teacher>()); -
*OBJ -> JSONObject
JSONObject jobj = (JSONObject)JSONObject.toJSON(obj);