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