public class GsonUtil { /** * 将object对象转成json格式字符串 */ public static String toJson(Object object) { GsonBuilder gsonBuilder = new GsonBuilder(); gsonBuilder.setPrettyPrinting(); Gson gson = gsonBuilder.create(); return gson.toJson(object); } }
测试工具类,将使用谷歌的gson将object对象转成josn对象
原文地址:https://www.cnblogs.com/qingmuchuanqi48/p/11628978.html
时间: 2024-09-29 11:34:02