Gson 是 Google 提供的用来在 Java 对象和 JSON 数据之间进行映射的 Java 类库。可以将一个 JSON 字符串转成一个 Java 对象,或者反过来。
项目链接:
https://github.com/google/gson
示例代码:
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"]
......
......
......
项目链接:
https://github.com/google/gson
示例代码:
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"]
......
......
......
本文介绍Gson库,由Google提供,用于实现Java对象与JSON数据之间的相互转换。Gson支持序列化Java对象为JSON字符串,也支持反序列化JSON数据为Java对象。示例展示了如何使用Gson进行基本的序列化操作。
143

被折叠的 条评论
为什么被折叠?



