public static Map returnMapByObject(Object object){ Map maps = (Map) JSON.parse(returnJsonByObject(object)); return maps; } /** * 利用 Gson 转换 object(Entity) 序列化为json,字符串 * */ public static String returnJsonByObject(Object object){ Gson gson = new GsonBuilder().enableComplexMapKeySerialization().create(); String jsonStr=gson.toJson(object); return jsonStr; }
Object转map(亲测好用)
最新推荐文章于 2023-05-24 16:18:03 发布