GsonJava 的 JSON 类库
Gson 是 Google 提供的用来在 Java 对象和 JSON 数据之间进行映射的 Java 类库。可以将一个 JSON 字符串转成一个 Java 对象,或者反过来。
示例代码:
Gson gson = new Gson();
 int[] ints = {1, 2, 3, 4, 5};
 String[] strings = {"abc", "def", "ghi"};
 
 (Serialization)
 gson.toJson(ints);     ==> prints [1,2,3,4,5]
 gson.toJson(strings);  ==> prints ["abc", "def", "ghi"]
评论
