com.github.duanxinyuan:library-json-jackson

Json工具类, 包含Gson、FastJson、Jackson三个库的工具类

License

License

Categories

Categories

JSON Data Jackson
GroupId

GroupId

com.github.duanxinyuan
ArtifactId

ArtifactId

library-json-jackson
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

Json工具类, 包含Gson、FastJson、Jackson三个库的工具类

Download library-json-jackson

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.duanxinyuan/library-json-jackson/ -->
<dependency>
    <groupId>com.github.duanxinyuan</groupId>
    <artifactId>library-json-jackson</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.duanxinyuan/library-json-jackson/
implementation 'com.github.duanxinyuan:library-json-jackson:1.1.0'
// https://jarcasting.com/artifacts/com.github.duanxinyuan/library-json-jackson/
implementation ("com.github.duanxinyuan:library-json-jackson:1.1.0")
'com.github.duanxinyuan:library-json-jackson:jar:1.1.0'
<dependency org="com.github.duanxinyuan" name="library-json-jackson" rev="1.1.0">
  <artifact name="library-json-jackson" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.duanxinyuan', module='library-json-jackson', version='1.1.0')
)
libraryDependencies += "com.github.duanxinyuan" % "library-json-jackson" % "1.1.0"
[com.github.duanxinyuan/library-json-jackson "1.1.0"]

Dependencies

compile (11)

Group / Artifact Type Version
com.fasterxml.jackson.module : jackson-module-parameter-names jar 2.9.6
com.fasterxml.jackson.datatype : jackson-datatype-jdk8 jar 2.9.6
com.fasterxml.jackson.datatype : jackson-datatype-jsr310 jar 2.9.6
com.fasterxml.jackson.datatype : jackson-datatype-guava jar 2.9.6
com.fasterxml.jackson.dataformat : jackson-dataformat-yaml jar 2.9.6
com.fasterxml.jackson.dataformat : jackson-dataformat-csv jar 2.9.6
com.fasterxml.jackson.dataformat : jackson-dataformat-xml jar 2.9.6
com.fasterxml.jackson.dataformat : jackson-dataformat-properties jar 2.9.6
org.apache.commons : commons-lang3 jar 3.8
org.slf4j : slf4j-api jar 1.7.25
org.projectlombok : lombok jar 1.16.20

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

json-utils

Json工具类, 包含Gson、FastJson、Jackson三个库的工具类,其中Jackson支持Scala版本

Maven依赖:

<dependencies>
<dependency>
    <groupId>com.github.duanxinyuan</groupId>
    <artifactId>json-fastjson</artifactId>
    <version>1.1.0</version>
</dependency>

<dependency>
    <groupId>com.github.duanxinyuan</groupId>
    <artifactId>json-gson</artifactId>
     <version>1.1.0</version>
</dependency>

<dependency>
    <groupId>com.github.duanxinyuan</groupId>
    <artifactId>json-jackson</artifactId>
    <version>1.1.0</version>
</dependency>

<dependency>
    <groupId>com.github.duanxinyuan</groupId>
    <artifactId>json-jackson-extend</artifactId>
    <version>1.1.0</version>
</dependency>

<dependency>
    <groupId>com.github.duanxinyuan</groupId>
    <artifactId>json-jackson-scala</artifactId>
    <version>1.1.0</version>
</dependency>
</dependencies>

Gson使用示例:

     //JSON反序列化
      Test test = GsonUtil.from(string, Test.class);
      
      //宽松JSON反序列化
      Test test = GsonUtil.fromLenient(string, Test.class);
      
      //JSON序列化
      String testStr = GsonUtil.to(test);
    
      //JSON序列化为文件
      GsonUtil.toFile(path, test);
      
      //JSON格式化
      String testStr = GsonUtil.format(test);
    
      //获取JSON中的单个字符串
      String name = GsonUtil.getAsString(string,"name");

Fastjson使用示例:

     //JSON反序列化
      Test test = FastjsonUtil.from(string, Test.class);
      
      //JSON格式化
      String testStr = FastjsonUtil.format(test);
    
      //JSON序列化
      String testStr = FastjsonUtil.to(test);
    
      //获取JSON中的单个字符串
      String name = FastjsonUtil.getAsString(string,"name");

Jackson使用示例:

    
    //JSON反序列化
    Test test = JacksonUtil.from(string, Test.class);
    
    //JSON格式化
    String testStr = JacksonUtil.format(test);
    
    //JSON序列化
    String testStr = JacksonUtil.to(test);
    
    //JSON序列化为文件
    String testStr = JacksonUtil.toFile(path, test);
    
    //获取JSON中的单个字符串
    String name = JacksonUtil.getAsString(string,"name");
    

Jackson-Extend使用示例:

    //反序列化Yaml
    Test test = JacksonExtendUtil.fromYamlResource(string, Test.class);
    Test test = JacksonExtendUtil.fromYamlFile(string, Test.class);
    
    //序列化为Yaml
    JacksonExtendUtil.toYaml(test);
  
    //序列化为Yaml文件
    JacksonExtendUtil.toYamlFile(path, test);
    
    //反序列化Properties
    Test test = JacksonExtendUtil.fromPropResource(string, Test.class);
        
    //序列化为Properties
    JacksonExtendUtil.toProp(test);
  
    //序列化为Properties文件
    JacksonExtendUtil.toPropFile(path, test);

    //反序列化Csv
    Test test = JacksonExtendUtil.fromCsvResource(string, Test.class);
    Test test = JacksonExtendUtil.fromCsvFile(string, Test.class);
          
    //序列化为Csv
    JacksonExtendUtil.toCsv(test);
  
    //序列化为Csv文件
    JacksonExtendUtil.toCsvFile(path, test);
    JacksonExtendUtil.toCsvFile(path, separator, test);

    //反序列化Xml
    Test test = JacksonExtendUtil.fromXmlResource(string, Test.class);
    Test test = JacksonExtendUtil.fromXmlFile(string, Test.class);
    Test test = JacksonExtendUtil.fromXml(string, Test.class);
         
    //序列化为Xml
    JacksonExtendUtil.toXml(test);
  
    //序列化为Xml文件
    JacksonExtendUtil.toXmlFile(path, test);

Versions

Version
1.1.0
1.0.0