Fastjson2

This article introduces Fastjson2 serialization

1 Introduction

FASTJSON v2 is an important upgrade of the FASTJSON project, aimed at providing a high-performance JSON library for the next decade. With the same API,

2 Usage

2.1 Add Dependency

  1. <dependencies>
  2. <dependency>
  3. <groupId>com.alibaba.fastjson2</groupId>
  4. <artifactId>fastjson2</artifactId>
  5. <version>2.0.23</version>
  6. </dependency>
  7. </dependencies>

Note: Fastjson2 serialization is only supported in Dubbo > 3.1.0. In Dubbo > 3.2.0, it will replace Hessian as the default serialization method.

2.2 Configure to Enable

  1. # application.yml (Spring Boot)
  2. dubbo:
  3. protocol:
  4. serialization: fastjson2

or

  1. # dubbo.properties
  2. dubbo.protocol.serialization=fastjson2
  3. # or
  4. dubbo.consumer.serialization=fastjson2
  5. # or
  6. dubbo.reference.com.demo.DemoService.serialization=fastjson2

or

  1. <dubbo:protocol serialization="fastjson2" />
  2. <!-- or -->
  3. <dubbo:consumer serialization="fastjson2" />
  4. <!-- or -->
  5. <dubbo:reference interface="xxx" serialization="fastjson2" />

Feedback

Was this page helpful?

Yes No

Last modified September 30, 2024: Update & Translate Overview Docs (#3040) (d37ebceaea7)