项目作者: qingmo

项目描述 :
Fastjson-replacement is a Bridge Pattern for developers or lagency projects which are used to Fastjson usage to replace Fastjson implementation with Jackson implementation.
高级语言: Kotlin
项目地址: git://github.com/qingmo/fastjson-replacement.git
创建时间: 2021-06-24T08:32:13Z
项目社区:https://github.com/qingmo/fastjson-replacement

开源协议:MIT License

下载


中文文档 | 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

  1. <dependency>
  2. <groupId>io.github.qingmo</groupId>
  3. <artifactId>fastjson-replacement</artifactId>
  4. <version>1.0.3</version>
  5. </dependency>

gradle

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

Use custom jacksonversion defined by user’s project

maven

  1. <dependency>
  2. <groupId>io.github.qingmo</groupId>
  3. <artifactId>fastjson-replacement</artifactId>
  4. <version>1.0.3</version>
  5. <exclusions>
  6. <exclusion>
  7. <groupId>com.fasterxml.jackson.core</groupId>
  8. <artifactId>jackson-databind</artifactId>
  9. </exclusion>
  10. <exclusion>
  11. <groupId>com.fasterxml.jackson.core</groupId>
  12. <artifactId>jackson-annotations</artifactId>
  13. </exclusion>
  14. <exclusion>
  15. <groupId>com.fasterxml.jackson</groupId>
  16. <artifactId>jackson-bom</artifactId>
  17. </exclusion>
  18. </exclusions>
  19. </dependency>

gradle

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

Step 2: Replace fastjson packages

Replace method

  1. import com.alibaba.fastjson.JSON
  2. replace with
  3. import io.github.qingmo.json.JSON
  4. import com.alibaba.fastjson.JSONArray
  5. replace with
  6. import io.github.qingmo.json.JSONArray
  7. import com.alibaba.fastjson.JSONObject
  8. replace with
  9. 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

References

jackson-datatype-fastjson

Jackson替换fastjson

如何让jackson与kotlin友好相处

jackson-replace-fastjson

Designing Data Intensive Applications