码迷,mamicode.com
首页 > Web开发 > 详细

初识json

时间:2019-06-26 13:55:56      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:需要   ToJson   --   解析   depend   end   collect   beanutils   对象   

josn包所需要的依赖有一下五个

<!-- 引入json依赖  -->

<dependency>
<groupId>net.sf.json-lib</groupId>
<artifactId>json-lib</artifactId>
<version>2.4</version>
<classifier>jdk15</classifier>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.7.0</version>
</dependency>
<dependency>
<groupId>commons-collections</groupId>
<artifactId>commons-collections</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>net.sf.ezmorph</groupId>
<artifactId>ezmorph</artifactId>
<version>1.0.3</version>
</dependency>

 

常用有三种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
      xml <!-- 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
      ````xml


      com.google.code.gson
      gson
      2.8.2

      ````

初识json

标签:需要   ToJson   --   解析   depend   end   collect   beanutils   对象   

原文地址:https://www.cnblogs.com/xinglongbing521/p/11089130.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!