AS插件-GsonFormat

概述

下载安装

https://github.com/zzz40500/GsonFormat

版本1.2.2 (中文)

支持 field 类型的修改.
支持快捷键打开 GsonFormat ,默认为 option+s(mac), alt+s(win)
支持 field 名称的修改.
支持添加 field 前缀.
支持多种转换库 (Gson,Jackjson,FastJson,LoganSquare).
支持 private 和 public 两种模式.
支持过滤父类已有属性.

方法1:

1.Android studio
File->Settings..->Plugins–>Browse repositores..搜索GsonFormat
2.安装插件,重启android studio

方法2: 下载地址

 1.下载 GsonFormat.jar ,
 2.Android studio  File->Settings..->Plugins -->

install plugin from disk..导入下载的 GsonFormat.jar ,
3重启 android studio .

使用

alt+insert 打开generate ,更多使用参考https://github.com/zzz40500/GsonFormat

json字符串:

{ "programmers": [ { "firstName": "Brett", "lastName":"McLaughlin", "email": "[email protected]" }, { "firstName": "Jason", "lastName":"Hunter", "email": "[email protected]" }, { "firstName": "Elliotte", "lastName":"Harold", "email": "[email protected]" } ],
"authors": [ { "firstName": "Isaac", "lastName": "Asimov", "genre": "science fiction" }, { "firstName": "Tad", "lastName": "Williams", "genre": "fantasy" }, { "firstName": "Frank", "lastName": "Peretti", "genre": "christian fiction" } ],
"musicians": [ { "firstName": "Eric", "lastName": "Clapton", "instrument": "guitar" }, { "firstName": "Sergei", "lastName": "Rachmaninoff", "instrument": "piano" } ] }

转换后的Code

package com.turing.base.activity.test;

import java.util.List;

/** * MyApp * * @author Mr.Yang on 2016-04-13 23:51. * @version 1.0 * @desc */
public class GsonFormat {


    /** * firstName : Brett * lastName : McLaughlin * email : [email protected] */

    private List<ProgrammersBean> programmers;
    /** * firstName : Isaac * lastName : Asimov * genre : science fiction */

    private List<AuthorsBean> authors;
    /** * firstName : Eric * lastName : Clapton * instrument : guitar */

    private List<MusiciansBean> musicians;

    public List<ProgrammersBean> getProgrammers() {
        return programmers;
    }

    public void setProgrammers(List<ProgrammersBean> programmers) {
        this.programmers = programmers;
    }

    public List<AuthorsBean> getAuthors() {
        return authors;
    }

    public void setAuthors(List<AuthorsBean> authors) {
        this.authors = authors;
    }

    public List<MusiciansBean> getMusicians() {
        return musicians;
    }

    public void setMusicians(List<MusiciansBean> musicians) {
        this.musicians = musicians;
    }

    public static class ProgrammersBean {
        private String firstName;
        private String lastName;
        private String email;

        public String getFirstName() {
            return firstName;
        }

        public void setFirstName(String firstName) {
            this.firstName = firstName;
        }

        public String getLastName() {
            return lastName;
        }

        public void setLastName(String lastName) {
            this.lastName = lastName;
        }

        public String getEmail() {
            return email;
        }

        public void setEmail(String email) {
            this.email = email;
        }
    }

    public static class AuthorsBean {
        private String firstName;
        private String lastName;
        private String genre;

        public String getFirstName() {
            return firstName;
        }

        public void setFirstName(String firstName) {
            this.firstName = firstName;
        }

        public String getLastName() {
            return lastName;
        }

        public void setLastName(String lastName) {
            this.lastName = lastName;
        }

        public String getGenre() {
            return genre;
        }

        public void setGenre(String genre) {
            this.genre = genre;
        }
    }

    public static class MusiciansBean {
        private String firstName;
        private String lastName;
        private String instrument;

        public String getFirstName() {
            return firstName;
        }

        public void setFirstName(String firstName) {
            this.firstName = firstName;
        }

        public String getLastName() {
            return lastName;
        }

        public void setLastName(String lastName) {
            this.lastName = lastName;
        }

        public String getInstrument() {
            return instrument;
        }

        public void setInstrument(String instrument) {
            this.instrument = instrument;
        }
    }
}

你可能感兴趣的:(AS插件-GsonFormat)