Idea安装GsonFormate插件
2021-05-12 本文已影响0人
亭台雨榭111
1.GsonFormate快速生成实体类,使用起来非常方便。下面说下Idea的安装步骤,以及使用方法
一、安装
1.点击File->settings

2.点击plugins->browse repositories->搜索GsonFormate ->install plugin

二、使用
1、按下快捷键alt + s ,弹出GsonFormate窗口,复制你要转成对象的json,点击formate(格式化一下),点击ok

2、点击ok后,窗口变为virgo Model窗口,可以修改json中的属性名称,数据类型等,修改完毕,点击ok,生成对象成功。

package com.focussend.common.entity;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
/**
* Created by Administrator on 2021/5/12.
*/
public class demo {
/**
* id : 1
* name : d1
* age : 12
*/
@SerializedName("id")
private Integer demoId;
private String name;
private int age;
public static demo objectFromData(String str) {
return new Gson().fromJson(str, demo.class);
}
public Integer getDemoId() {
return demoId;
}
public void setDemoId(Integer demoId) {
this.demoId = demoId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}