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>
    
    


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM