GithubHelp home page GithubHelp logo

json-java's Introduction

JSON

Introduction

朴素的 JSON 序列化工具. 基于 Field 实现.

速度不快, 只是避免较多反序列化漏洞而诞生.

支持类型:

  1. JSON ORM by serialize/deserialize
  2. 支持 enum
  3. 支持 范型 (But @author 不推荐使用)
  4. 支持 pretty
  5. 各种日期, 序列化成 string = "yyyy-MM-dd HH:mm:ss" 格式

推荐:

  1. 尽量使用纯实体的数据结构, 而非 interface / abstract 作为 json 载体.
  2. 不追求速度
  3. 删减第三方依赖, 和第二方工具库

Download

maven

<dependency>
    <groupId>com.neko233</groupId>
    <artifactId>json-java</artifactId>
    <version>0.3.0</version>
</dependency>

gradle

implementation("com.neko233:json-java:0.3.0")

JMH Speed Test

jmh-metrics-by-ms.png

测速结论:

  1. 线性增长耗时。

单个 object serialize ~= 100w+/s 单个 object serialize + deserialize ~= 30+w/s 数组 object serialize + deserialize ~= 100w+ / n 个对象 /s 3 object List ~= 32w+/s 数组 object serialize + deserialize ~= 30+w / n 个对象 /s 3 object list ~= 10w+/s

JDK Compatibility | JDK 版本支持

Latest supported versions:

JDK 8 = 0.3.0

JDK 11 = 0.3.0

JDK 17 = 0.3.0

Key Terminology | 术语

  1. serialize: 序列化. JSON String -> Object
  2. deserialize : 反序列化. Object -> JSON String

License

json-java is licensed under Apache 2.0.

Download

Maven

<dependency>
    <groupId>com.neko233</groupId>
    <artifactId>json-java</artifactId>
    <version>0.3.0</version>
</dependency>

Gradle

implementation group: 'com.neko233', name: 'json-java', version: '0.3.0'

Code

Demo

        String serialize=JSON.serialize(person);
        Person reTestSpeedPerson=JSON.deserialize(serialize,Person.class);

        System.out.println("original = "+person);
        System.out.println("deserialize = "+reTestSpeedPerson);

        Assert.assertTrue(reTestSpeedPerson.equals(person));

json-java's People

Contributors

solarisneko avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.