Languages
[Edit]
EN

Spring Boot 2 - configure Fastjson as default JSON library (Jackson replacement)

9 points
Created by:
Tyreese-Aguirre
379

In this short article, we would like to show how to use Alibaba Fastjson library in Spring Boot 2 (or 3 also).

By default Spring Boot 2/3 uses Jackson library to convert Java objects to JSONs and back, so there are needed to do some changes in configurations.

Practical example

Edit

It is necessary to:

  • exclude default Jackson library,
  • include Fastjson library,
  • include Fastjson Spring extension library,
  • add FastJsonHttpMessageConverter configuration.

 

In pom.xml file do the following changes:

 

Add JsonMapperConfig.java file to application configurations:

 

Custom usage

Edit

Manually in our source code we are able to convert:

1. Objects to JSONs by:

2. JSONs to Objects by:

 

References

Edit
  1. Alibaba Fastjson - GitHub Repository
  2. com.alibaba.fastjson2/fastjson2/2.0.51 - Maven Repository
  3. com.alibaba.fastjson2/fastjson2-extension-spring6/2.0.51 - Maven Repository

Alternative titles

  1. Spring Boot 3 - configure Fastjson as default JSON library (as default Jackson replacement)
  2. Spring Boot 2 - use Fastjson as default JSON library (as default Jackson replacement)
  3. Spring Boot 3 - use Fastjson as default JSON library (as default Jackson replacement)
  4. Spring Boot 2 - configure Alibaba Fastjson as default JSON library (Jackson replacement)
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join