内容简介:一、引言spring boot默认的json解析是 jackson方法1:
一、引言
spring boot默认的json解析是 jackson
可以引入阿里的 fastjson 为什么引入fastjson?(个人认为) 1、相对较快 2、支持国产 SpringBoot 整合 fastjson解析JSON数据 方式有两种:
方法1:
在启动类中,注入Bean:HttpMessageConverters
方法2:
a、SpringBoot2.0 以下的版本
(1)继承extends WebMvcConfigurerAdapter
(2)覆盖方法configureMessageConverters
b、SpringBoot2.0 以上版本
在SpringBoot2.0及Spring 5.0 WebMvcConfigurerAdapter已被废弃,目前找到解决方案
二、开发步骤
1、引入fastjson 依赖库
这里要说下很重要的话,官方文档说的1.2.10以后,会有两个方法支持HttpMessageconvert,一个是FastJsonHttpMessageConverter,支持4.2以下的版本,一个是FastJsonHttpMessageConverter4支持4.2以上的版本,具体有什么区别暂时没有深入研究。这里也就是说:低版本的就不支持了,所以这里最低要求就是1.2.10+。
2、准备基本的数据
3、fastjson 转换方法有2 种
a> 方法一:在启动类中,注入Bean:HttpMessageConverters
b> 方式二:
(1)继承extends WebMvcConfigurerAdapter (2)覆盖方法configureMessageConverters
4、测试
浏览器效果如下:
以上所述就是小编给大家介绍的《fastjson》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- fastjson-1.2.41 和 fastjson-1.1.67.android 发布
- fastjson
- fastjson反序列化复现
- FastJson 反序列化学习
- Fastjson 究竟犯了哪些错?
- Fastjson反序列化漏洞利用
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
An Introduction to Probability Theory and Its Applications
William Feller / Wiley / 1991-1-1 / USD 120.00
Major changes in this edition include the substitution of probabilistic arguments for combinatorial artifices, and the addition of new sections on branching processes, Markov chains, and the De Moivre......一起来看看 《An Introduction to Probability Theory and Its Applications》 这本书的介绍吧!
JS 压缩/解压工具
在线压缩/解压 JS 代码
XML、JSON 在线转换
在线XML、JSON转换工具