Skip to content

从JSON生成POJO类,并添加lombok和gson/jackson标注。

License

Notifications You must be signed in to change notification settings

zenglian/json2pojo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

中文 README

Introduction

An IntelliJ Idea plugin which generate POJOs from JSON with Lombok and gson/jackson annotations.

Installation

From IntelliJ Idea plugin marketplace search json2pojo with Lombok.

Usage

  1. From context of a package,select "New-> Generate POJOs from JSON".

Context menu

  1. Input root class name and source JSON.

Input UI

Settings

Settings UI

Settings file ~/.json2pojo

{
  "primitive": true,
  "field.name.annotation": 1,
  "lombok.accessors": false,
  "lombok.accessors.fluent": true,
  "lombok.accessors.chain": true,
  "lombok.accessors.prefix": "",
  "lombok.builder": false,
  "lombok.data": true,
  "lombok.no.args.constructor": false,
  "lombok.required.args.constructor": true,
  "lombok.all.args.constructor": false
}

Example

Run GeneratorTest, generated root class:

package example.spark;

import java.util.List;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@Data
@SuppressWarnings("unused")
public class SparkProgress {
    @SerializedName("batch.id")
    private long batchId;
    private DurationMs durationMs;
    private String id;
    @SerializedName("input-rows-per-second")
    private double inputRowsPerSecond;
    private String name;
    @SerializedName("num_input_rows")
    private long numInputRows;
    private double processedRowsPerSecond;
    private String runId;
    private Sink sink;
    private List<Source> sources;
    private List<StateOperator> stateOperators;
    private String timestamp;
}

About

从JSON生成POJO类,并添加lombok和gson/jackson标注。

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages