Git Product home page Git Product logo

serializednamegen's Introduction

Gson SerializedName Gen


GsonSerializedNameGen 是一个自动生成Gson SerializedName注解的插件。

IEDA插件仓库地址

插件下载地址

插件Github地址

介绍

有时候经常会维护一些老的项目,可能由于历史或开发人员能力问题,代码会稍微不规范。

比如在请求网络数据时会需要把json反序列化成实体,然后下面是常见的一种方式。

public class Bean {

    public String Name;

    public int max_age;
    
    public class InnerA {

        public String Name;

        public int max_age;
    }

    public static class InnerB {

        public String Name;

        public int max_age;
    }
}

上面的代码是很规范的,首先代码中字段名字命名规则是不满足驼峰规则的,其次需要添加json别名注解,比如常见的Gson,需要添加@SerializedName注解,否则不能进行代码混淆。

一些有强迫症的程序员就会手动修改这些代码,但是是历史代码,可能一不小心就改坏了,修改需要一定的工作量,并且是重复劳动的工作,那么此工具就是干这样的事情的,使用工具优化后,就变成了下面样子。

public class Bean {

    @SerializedName("Name")
    public String Name;

    @SerializedName("max_age")
    public int max_age;
    
    public class InnerA {

        @SerializedName("Name")
        public String Name;

        @SerializedName("max_age")
        public int max_age;
    }

    public static class InnerB {

        @SerializedName("Name")
        public String Name;

        @SerializedName("max_age")
        public int max_age;
    }
}

使用姿势

支持特性

  • 支持Gson SerializedName 注解添加与删除
  • 支持Fastjson JSONField 注解添加与删除
  • 支持Jackson JsonProperty 注解添加与删除
  • 支持Java & Kotlin语言

插件下载

IEDA插件仓库地址

插件下载地址

搜索 SerializedName Tool

插件安装

示例演示

示例演示

规则配置

示例演示

其他

第一个版本,实现有点仓促,如果有问题,欢迎交流,[email protected]

后续规划

  • 支持Kotlin语言
  • 支持删除某一种json序列化工具别名
  • 支持其他方式json序列化工具

其他工具

SerializedNameGen

AutoValueConvert

DatabindingConvert

日志

v0.8

  • 添加FirstUppercase生成规则
  • 生成规则
    • Origin
    • Uppercase
    • FirstUppercase
    • Lowercase
    • Underline
    • Smart

v0.7

  • 支持生成规则配置
  • 生成规则
    • Origin
    • Uppercase
    • Lowercase
    • Underline
    • Smart

v0.4

  • 支持Gson SerializedName 注解添加与删除
  • 支持Fastjson JSONField 注解添加与删除
  • 支持Jackson JsonProperty 注解添加与删除
  • 支持Java & Kotlin语言

v0.3

  • 支持 Gson SerializedName 的删除

v0.2

  • 优化代码

v0.1

  • 第一个版本,实现基本功能,支持添加Gson SerializedName

serializednamegen's People

Contributors

liushuixiaoxia avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

serializednamegen's Issues

可否增加一个驼峰转下划线功能

java的命名规则习惯使用驼峰,json中的原始数据有时是下划线。
把json中的下划线属性转换成java中的驼峰属性需要写大量重复代码。
可否有空支持一个这样的功能,多谢!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.