美文网首页
Gson 使用简记

Gson 使用简记

作者: 几千里也 | 来源:发表于2019-11-25 19:55 被阅读0次

Gson User Guide

Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to an equivalent Java object.

引用 Gson

// 表明版本号
implementation 'com.google.code.gson:gson:2.8.6'
//或者用最新版本
implementation 'com.google.code.gson:gson:latest.release'

创建对象

使用 Gson 构造方法创建 Gson gson = new Gson();
使用 GsonBuilder 创建 Gson gson = new GsonBuilder().create();
Builder 方式支持对 Gson 的配置,相比使用构造方法更加灵活。

今天先到这里,明天继续……

相关文章

网友评论

      本文标题:Gson 使用简记

      本文链接:https://www.haomeiwen.com/subject/xpsjwctx.html