记录GsonFormat插件的使用

. 插件功能:
根据json格式的字符串,在android studio或者Intellij IDEA平台上自动生成对应的类(对象or实体)

. 使用步骤(android studio):
1.安装GsonFormat插件
File -> Settings ->Plugins -> Browse Repositories -> 搜索框里搜索GsonFormat -> 点击安装 -> 重启android studio
2.new一个类(类名自定义如bean)
3.打开GsonFormat的对话框
Code -> Generate -> GsonFormat (可以自定义快捷键,然后用快捷键打开,自定义为Alt + a)
4.将json字符串复制到对话框里,-> Format -> OK
5.自动生成对应的类
.效果如下所示:
json 数据

 {
      "_id": "58de5542421aa969fd8a3df9", 
      "createdAt": "2017-03-31T21:10:26.504Z", 
      "desc": "\u7b2c\u4e09\u65b9SDK\u96c6\u6210\u5e93(\u6388\u6743/\u5206\u4eab/\u652f\u4ed8)", 
      "publishedAt": "2017-04-13T11:36:04.435Z", 
      "source": "web", 
      "type": "Android", 
      "url": "https://github.com/czy1121/sdk3rd", 
      "used": true, 
      "who": "ezy"
    }

自动生成的类

public class Bean {
    /**
     * _id : 58de5542421aa969fd8a3df9
     * createdAt : 2017-03-31T21:10:26.504Z
     * desc : 第三方SDK集成库(授权/分享/支付)
     * publishedAt : 2017-04-13T11:36:04.435Z
     * source : web
     * type : Android
     * url : https://github.com/czy1121/sdk3rd
     * used : true
     * who : ezy
     */

    private String _id;
    private String createdAt;
    private String desc;
    private String publishedAt;
    private String source;
    private String type;
    private String url;
    private boolean used;
    private String who;

    public String get_id() {
        return _id;
    }

    public void set_id(String _id) {
        this._id = _id;
    }

    public String getCreatedAt() {
        return createdAt;
    }

    public void setCreatedAt(String createdAt) {
        this.createdAt = createdAt;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getPublishedAt() {
        return publishedAt;
    }

    public void setPublishedAt(String publishedAt) {
        this.publishedAt = publishedAt;
    }

    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public boolean isUsed() {
        return used;
    }

    public void setUsed(boolean used) {
        this.used = used;
    }

    public String getWho() {
        return who;
    }

    public void setWho(String who) {
        this.who = who;
    }
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值