zoukankan      html  css  js  c++  java
  • springboot使用fastjson解析json数据

    一、配置pon.xml

    <!-- fastjson的依赖 -->
    <dependency>
        <groupId>com.alibaba</groupId>
        <artifactId>fastjson</artifactId>
        <version>1.2.15</version>
    </dependency>

    二、配置注入

    @Bean
    public HttpMessageConverters fastJsonMessageConverter() {
        // 创建FastJson的消息转换器
        FastJsonHttpMessageConverter convert = new FastJsonHttpMessageConverter();
        // 创建FastJson的配置对象
        FastJsonConfig config = new FastJsonConfig();
        // 对Json数据进行格式化
        config.setSerializerFeatures(SerializerFeature.PrettyFormat);
    
        convert.setFastJsonConfig(config);
        HttpMessageConverter<?> con = convert;
        return new HttpMessageConverters(con);
    }

    三、配置application.yml

    spring:
      http:
        encoding:
          force: true

    四、fastjson注解

    @JSONField(format="yyyy-MM-dd HH:mm:ss")    // 格式化日期
  • 相关阅读:
    正则表达式
    HDU 2066 多源最短路
    UVA 11039 模拟
    Concrete Mathematics Chapter 1 Warmups
    List differences between JAVA and C++
    uva 11107Life Forms
    poj 1509 Glass Beads
    poj 3581
    网络流建图
    图论算法----网络流
  • 原文地址:https://www.cnblogs.com/linding/p/12591398.html
Copyright © 2011-2022 走看看