Skip to content

Fastjson-replacement is a Bridge Pattern for developers or lagency projects which are used to Fastjson usage to replace Fastjson implementation with Jackson implementation.

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
license.txt
Notifications You must be signed in to change notification settings

qingmo/fastjson-replacement

Repository files navigation

中文文档 | English Document

Fastjson-replacement

codecov License quality gate Codacy Security Scan build

Current version of 1.0.3 is product ready.

What's Fastjson-replacement?

Fastjson-replacement is a Bridge Pattern for developers or lagency projects which are used to Fastjson usage to replace
Fastjson implementation with Jackson implementation.

Features

  • support java.util.Date, java 8 jsr310 time packages(LocalDate,LocalDateTime,LocalTime)
  • support multiple Date Format Deserialize(Current:yyyy-MM-dd HH:mm:ss,yyyy-MM-dd)

Why

Why do we need replace fastjson? For it security issues, late of fix period and so on.

Why make new tools instead of using existing one? Because their bad tests(even in fastjson), and not auto publish after merged my pull requests that make me can not get new fix version from maven central repository.

How to Use

Step 1: Add Dependencies

Use default jacksonversion(current version is:1.12.3) proivded by current lib.

maven

<dependency>
    <groupId>io.github.qingmo</groupId>
    <artifactId>fastjson-replacement</artifactId>
    <version>1.0.3</version>
</dependency>

gradle

implementation("io.github.qingmo:fastjson-replacement:1.0.3")

Use custom jacksonversion defined by user's project

maven

<dependency>
    <groupId>io.github.qingmo</groupId>
    <artifactId>fastjson-replacement</artifactId>
    <version>1.0.3</version>
    <exclusions>
        <exclusion>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </exclusion>
        <exclusion>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
        </exclusion>
        <exclusion>
            <groupId>com.fasterxml.jackson</groupId>
            <artifactId>jackson-bom</artifactId>
        </exclusion>
    </exclusions>
</dependency>

gradle

implementation("io.github.qingmo:fastjson-replacement:1.0.3") {
    exclude(group = "com.fasterxml.jackson.core")
    exclude(group = "com.fasterxml.jackson")
}

Step 2: Replace fastjson packages

Replace method

import com.alibaba.fastjson.JSON
replace with
import io.github.qingmo.json.JSON

import com.alibaba.fastjson.JSONArray
replace with
import io.github.qingmo.json.JSONArray

import com.alibaba.fastjson.JSONObject
replace with
import io.github.qingmo.json.JSONObject

What's the importance of the enterprise environment for an open-source library?

  • Reliability

    The system/library must work correctly. Fastjson-replacement provide functions with 100% tests coverage.

  • Performance

    The system/library must perform the function at the desired level of performance. if this library is the only solution to a problem, the performance should be at tolerant level; if this library is another solution to a problem, the performance should be equal to or better than the average level.

    Fastjson-replacement provide benchmark records as below(base on json-comparsion):

    serialize_benchmark

    deserialize_benchmark

Known Issues

  • not support kotin data class

    kotlin data class need jackson-module-kotlin which depends on kotlin-reflect bad benchmark scores in deserialize. i'm waiting for FasterXML/jackson-module-kotlin#439

References

jackson-datatype-fastjson

Jackson替换fastjson

如何让jackson与kotlin友好相处

jackson-replace-fastjson

Designing Data Intensive Applications

About

Fastjson-replacement is a Bridge Pattern for developers or lagency projects which are used to Fastjson usage to replace Fastjson implementation with Jackson implementation.

Topics

Resources

License

MIT, MIT licenses found

Licenses found

MIT
LICENSE
MIT
license.txt

Stars

Watchers

Forks

Packages

No packages published