SpringBoot阿里巴巴Fastjson的一些常用配置
SpringBoot阿里巴巴Fastjson的一些常用配置
@Bean
public HttpMessageConverters fastJsonHttpMessageConverters() {
FastJsonHttpMessageConverter fastConverter = new FastJsonHttpMessageConverter();
FastJsonConfig fastJsonConfig = new FastJsonConfig();
fastJsonConfig.setSerializerFeatures(
SerializerFeature.PrettyFormat, //是否格式化输出,默认为false
SerializerFeature.DisableCircularReferenceDetect, //禁止循环引用,即出现$.data[0]
SerializerFeature.WriteMapNullValue, //Map字段如果为null,输出为[],而非null
SerializerFeature.WriteNullListAsEmpty, //List字段如果为null,输出为[],而非null
SerializerFeature.WriteNullStringAsEmpty //字符类型字段如果为null,输出为”“,而非null
);
fastJsonConfig.setDateFormat("yyyy-MM-dd HH:mm:ss"); //统一配置日期格式
fastJsonConfig.setCharset(Charset.forName("UTF-8"));
fastConverter.setFastJsonConfig(fastJsonConfig);
HttpMessageConverter<?> converter = fastConverter;
return new HttpMessageConverters(converter);
}
当配置了“SerializerFeature.WriteMapNullValue”这一类配置之后,当返回值中的该字段为null,将输出字段,如果不配置,那该字段将不会显示
引用文章:https://blog.csdn.net/u010246789/article/details/52539576
SpringBoot阿里巴巴Fastjson的一些常用配置的更多相关文章
- SpringBoot常用配置简介
SpringBoot常用配置简介 1. SpringBoot中几个常用的配置的简单介绍 一个简单的Spring.factories # Bootstrap components org.springf ...
- Gradle基本知识点与常用配置
查看原文:http://blog.csdn.net/u010818425/article/details/52268126 本文篇幅较长,文中系统地讲解了Gradle的基本知识点以及一些常用的命令和配 ...
- 阿里巴巴fastJson
FastJson解析 一.阿里巴巴FastJson是一个Json处理工具包,包括“序列化”和“反序列化”两部分,它具备如下特征:速度最快,测试表明,fastjson具有极快的性能,超越任其他的Java ...
- springboot之jackson的两种配置方式
springboot 针对jackson是自动化配置的,如果需要修改,有两种方式: 方式一:通过application.yml 配置属性说明:## spring.jackson.date-format ...
- dubbo的常用配置(基于注解)
之前记录了基于springboot的dubbo入门案例,今天在此基础上记录dubbo官网介绍的常用属性配置,dubbo读取我们配置的属性时是有优先级的,优先级如下图: 如图所示,优先级的属性依次为虚拟 ...
- springboot整合fastJson遇到重定向问题
通过网上教程使用springboot整合fastJson后遇到页面重定向问题(使用的springboot版本是2.0.2.RELEASE ,其他的版本可能不会出现以下问题),如下图: 我的项目结构如下 ...
- Dubbo在开发中的一些常用配置
介绍Dubbo在开发中的一些常用配置,文中内容主要参考dubbo文档配置和示例两节,详细可移步访问 传送站 1. 属性配置方法及加载顺序 属性常用配置方法主要有三种: 第一种是通过启动时在虚拟机参数 ...
- springboot(十三)-分库分表-手动配置
sharding-jdbc简介 Sharding-JDBC直接封装JDBC API,可以理解为增强版的JDBC驱动,旧代码迁移成本几乎为零: 可适用于任何基于java的ORM框架,如:JPA, Hib ...
- springboot使用fastJson作为json解析框架
springboot使用fastJson作为json解析框架 springboot默认自带json解析框架,默认使用jackson,如果使用fastjson,可以按照下列方式配置使用 〇.搭建spri ...
随机推荐
- 面向对象——单例模式,五种方式
单例模式:多次实例化的结果指向同一个实例 实现方式 一.使用类方法(调用创新对象,函数返回原定对象) import settings class Mysql: __instance = None de ...
- Python random模块 获取随机数的使用
random.randomrandom.random()用于生成一个0到1的随机符点数: 0 <= n < 1.0 random.uniformrandom.uniform(a, b),用 ...
- 模拟ssh、黏包、hashlib模块
一.模拟ssh 1.subprocess模块 ipconfig -all dir subprocess模块是python从2.4版本开始引入的模块.主要用来取代 一些旧的模块方法,如os.system ...
- Windows 出现了回声 & 微软账号无法登陆
Windows 出现了回声,第一反应是杜比音效偷偷背着我开启了客厅模式(后面看了下并没有这个模式,后话了...). 再我尝试打开它发现提示网络无法连接,于是我就直接卸载了,但回声依能没有解决. 后面我 ...
- typescript-koa-postgresql 实现一个简单的rest风格服务器 —— 集成 koa
接上文 1.安装 koa yarn add koa koa-router koa-static yarn add @types/koa @types/koa-router @types/koa-sta ...
- POJ 2560
#include<iostream> #include<algorithm> #include<cmath> #include<iomanip> #de ...
- python2 里边自定义线程池
#!/usr/bin/env python # -*- coding:utf-8 -*- import Queue import threading class ThreadPool(object): ...
- (转)Python内置函数进阶之“属性(property())”详解
原文:https://blog.csdn.net/GeekLeee/article/details/78519767 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.c ...
- java Queue的用法
https://www.cnblogs.com/caozengling/p/5307992.html https://blog.csdn.net/a724888/article/details/802 ...
- drools 的一个小demo
直接上代码: 第一步,maven引入相关包 <?xml version="1.0" encoding="UTF-8"?> <project x ...