Fastjson

This article introduces Fastjson serialization

1 Introduction

Fastjson is a Java library used to convert Java objects to their JSON representation. It can also be used to convert JSON strings to equivalent Java objects. Fastjson can handle any Java object, including pre-existing objects for which you do not have source code.

2 How to Use

2.1 Adding Dependencies

  1. <dependencies>
  2. <dependency>
  3. <groupId>org.apache.dubbo.extensions</groupId>
  4. <artifactId>dubbo-serialization-fastjson</artifactId>
  5. <version>3.3.0</version>
  6. </dependency>
  7. <dependency>
  8. <groupId>com.alibaba</groupId>
  9. <artifactId>fastjson</artifactId>
  10. <version>1.2.83</version>
  11. </dependency>
  12. </dependencies>

2.2 Configuration Enabling

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

or

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

or

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

3 Supported RPC Protocols

Feedback

Was this page helpful?

Yes No

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