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>
    
    
posted @ 2018-04-24 14:07  硅谷工具人  阅读(72113)  评论(0编辑  收藏  举报
成功之道,在于每个人生阶段都要有不同的目标,并且通过努力实现自己的目标,毕竟人生不过百年! 所有奋斗的意义在于为个人目标实现和提升家庭幸福,同时能推进社会进步和国家目标! 正如古人讲的正心诚意格物致知,修身齐家治国平天下。