Spring boot uses fastjson to parse JSON data

The JSON framework I am used to is fastjson, so the default JSON of spring boot is very strange to use, so naturally I wonder if I can use fastjson for JSON parsing?

1. Introduce fastjson dependency Library:

2. Configure fastjson

Here I want to say something very important. The official document says 1.2 After 10, there will be two methods to support httpmessageconvert. One is fastjsonhttpmessageconverter, which supports versions below 4.2, and the other is fastjsonhttpmessageconverter 4, which supports versions above 4.2. There is no in-depth study on the specific difference. This means that the lower version is not supported, so the minimum requirement here is 1.2 10+

Mode 1:

(1) The startup class inherits webmvcconfigureradapter

(2) Override method configuremessageconverters

Specific code:

Mode 2:

In the configuration class or startup class, inject bean: httpmessageconverters

After configuration, use @ jsonfield (serialize = false) in the entity class. Does this field not return? If so, congratulations on your successful configuration. The package path of jsonfield is: com alibaba. fastjson. annotation. JSONField

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>