• JSON对应的maven依赖包


    常用有三种json解析jackson、fastjson、gson。

    1. jackson依赖包

      		<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
      	<dependency>
      	    <groupId>com.fasterxml.jackson.core</groupId>
      	    <artifactId>jackson-databind</artifactId>
      	    <version>2.9.3</version>
      	</dependency>
      	<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->
      	<dependency>
      	    <groupId>com.fasterxml.jackson.core</groupId>
      	    <artifactId>jackson-core</artifactId>
      	    <version>2.9.3</version>
      	</dependency>
      	<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-annotations -->
      	<dependency>
      	    <groupId>com.fasterxml.jackson.core</groupId>
      	    <artifactId>jackson-annotations</artifactId>
      	    <version>2.9.3</version>
      	</dependency>
      
    2. fastjson

      <!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
      <dependency>
          <groupId>com.alibaba</groupId>
          <artifactId>fastjson</artifactId>
          <version>1.2.47</version>
      </dependency>
      

      遇到对象转json字符串时,如果对象中的属性字段为null,则不会显示出来。解决方法

      JSONObject.toJSONString(bean,SerializerFeature.WriteMapNullValue)

    3. gson

      <!-- https://mvnrepository.com/artifact/com.google.code.gson/gson -->
      <dependency>
          <groupId>com.google.code.gson</groupId>
          <artifactId>gson</artifactId>
          <version>2.8.2</version>
      </dependency>
      
      
  • 相关阅读:
    一月十三号学习日报
    一月十四号学习日报
    一月六号学习日报
    ARP欺骗
    一月十一号学习日报
    vscode文件名重叠
    vue : 无法加载文件 C:Users1111111AppDataRoaming pmvue.ps1,因为在此系统禁止运行脚本
    成绩录入和查询
    node搭建服务器
    class和id的区别
  • 原文地址:https://www.cnblogs.com/30go/p/8929898.html
Copyright © 2020-2023  润新知