gson之将对象转化成json字符串的方法
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对象
本文来自博客园,作者:King-DA,转载请注明原文链接:https://www.cnblogs.com/qingmuchuanqi48/p/11628978.html