1. 方式一 直接在线生成
2. 方式二 调用接口生成
引入gson-2.8.5.jar
可以通过maven仓库搜索下载地址
import com.google.gson.annotations.SerializedName;
/**
* @program: javaTest1.8
* @description: 响应结果
* @author: Mr.Wang
* @create: 2019-05-31 12:56
**/
public class UrlResponse {
//@SerializedName注解来将对象里的属性跟json里字段对应值匹配起来。
@SerializedName("Code")
private int code;
@SerializedName("ErrMsg")
private String errMsg; //错误信息
@SerializedName("LongUrl")
private String longUrl; //长网址(原网址)
@SerializedName("ShortUrl")
private String shortUrl; //短网址
public int getCode() {
<