zoukankan      html  css  js  c++  java
  • springboot 针对jackson是自动化配置

    spring.jackson.date-format指定日期格式,比如yyyy-MM-dd HH:mm:ss,或者具体的格式化类的全限定名

    spring.jackson.deserialization是否开启Jackson的反序列化

    spring.jackson.generator是否开启json的generators.

    spring.jackson.joda-date-time-format指定Joda date/time的格式,比如yyyy-MM-ddHH:mm:ss). 如果没有配置的话,dateformat会作为backup

    spring.jackson.locale指定json使用的Locale.

    spring.jackson.mapper是否开启Jackson通用的特性.

    spring.jackson.parser是否开启jackson的parser特性.

    spring.jackson.property-naming-strategy指定PropertyNamingStrategy(CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES)或者指定PropertyNamingStrategy子类的全限定类名.

    spring.jackson.serialization是否开启jackson的序列化.

    spring.jackson.serialization-inclusion指定序列化时属性的inclusion方式,具体查看JsonInclude.Include枚举.

    spring.jackson.time-zone指定日期格式化时区,比如America/Los_Angeles或者GMT+8.

    第一种:application.properties文件

    spring.jackson.date-format=yyyy-MM-dd HH:mm:ss 
    spring.jackson.time-zone=GMT+8
    spring.jackson.serialization-inclusion=non_null
    

      

    第二种:application.yml文件

    spring:
      jackson:
        #日期格式化
        date-format: yyyy-MM-dd HH:mm:ss
        serialization:
           #格式化输出 
          indent_output: true
          #忽略无法转换的对象
          fail_on_empty_beans: false
        #设置空如何序列化
        defaultPropertyInclusion: NON_EMPTY
        deserialization:
          #允许对象忽略json中不存在的属性
          fail_on_unknown_properties: false
        parser:
          #允许出现特殊字符和转义符
          allow_unquoted_control_chars: true
          #允许出现单引号
          allow_single_quotes: true
    

      JsonInclude:

    JsonInclude.Include.ALWAYS              默认
    
    JsonInclude.Include.NON_DEFAULT     属性为默认值不序列化
    
    JsonInclude.Include.NON_EMPTY         属性为 空(””) 或者为 NULL 都不序列化
    
    JsonInclude.Include.NON_NULL           属性为NULL   不序列化
    

    第三种:实体上使用 @JsonInclude(JsonInclude.Include.NON_NULL)

                  jackson实体转json时,某个属性不参加序列化时 使用@JsonIgnore 放在该属性上

  • 相关阅读:
    is running beyond physical memory limits. Current usage: 2.0 GB of 2 GB physical memory used; 2.6 GB of 40 GB virtual memory used
    saiku执行速度优化二
    saiku执行速度慢
    saiku 升级&备份&恢复
    saiku 展示优化第二步(要诀和技巧)
    saiku 无密码登陆
    saiku 展示优化
    saiku源代码安装
    结合使用saiku、mondrian workbentch建立多维查询报表
    浅析 mondrian 模式文件 Schema
  • 原文地址:https://www.cnblogs.com/shihaibin821/p/9999530.html
Copyright © 2011-2022 走看看