安装
方法一:
1.Android studio File->Settings..->Plugins–>Browse repositores..搜索GsonFormat
2.安装插件,重启android studio
方法二:
1.下载GsonFormat.jar ;
2.Android studio File->Settings..->Plugins –>install plugin from disk..导入下载GsonFormat.jar
3.重启android studio
使用方法
在实体类中使用Generate的快捷键.
快捷键:图中选中的部分
简单的实体类
图中简单的 json 格式
{
"name": "王五",
"gender": "man",
"age": 15,
"height": "140cm",
}
生成结果:
package zhangxueyuan.myapplication;
/**
* Created by xueyuan on 2015/6/15.
*/
public class Bean {
/**
* height : 140cm
* age : 15
* name : 王五
* gender : man
*/
private String height;
private int age;
private String name;
private String gender;
public void setHeight(String height) {
this.height = height;
}
public void setAge(int age) {
this.age = age;
}
public void setName(String name) {
this.name = name;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getHeight() {
return height;
}
public int getAge() {
return age;
}
public String getName() {
return name;
}
public String getGender() {
return gender;
}
}
发现不需要继承JSONModle.
标签:插件,String,gender,age,height,AndroidStudio,GsonFormat,public,name From: https://blog.51cto.com/u_16099425/6249586