zoukankan      html  css  js  c++  java
  • 初识json

    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

        ````

  • 相关阅读:
    OCP-1Z0-051-V9.02-80题
    OCP-1Z0-051-V9.02-124题
    Flex中的HDividedBox和VDividedBox的比较
    Flex中AdvancedDataGrid的用法
    IDA,很好很强大
    AndroidManifest.xml文件中加入文件控制控制权限
    OCP-1Z0-051-V9.02-6题
    OCP-1Z0-051-V9.02-5题
    OCP-1Z0-051-V9.02-4题
    Android Eclipse JNI 调用 .so文件加载问题
  • 原文地址:https://www.cnblogs.com/xinglongbing521/p/11089130.html
Copyright © 2011-2022 走看看