故障代码

    @Testpublic void parserJsonTxt() throws IOException{ClassLoader cl = this.getClass().getClassLoader();InputStream inputStream = cl.getResourceAsStream("data1.json");System.out.print(inputStream);String jsontext = IOUtils.toString(inputStream, "utf8");JSONObject obj=JSONObject.parseObject(jsontext);//获取jsonobject对象JSONObject obj1 = obj.getJSONObject("data");JSONArray jsonArray = obj1.getJSONArray("rows");System.out.println("jsonArray:"+jsonArray);JSONObject obj2 = jsonArray.getJSONObject(1);System.out.println("obj2:" +obj2);for(Iterator iterator = jsonArray.iterator(); iterator.hasNext();) {JSONObject jsonObject1 = (JSONObject) iterator.next();System.out.println(jsonObject1);}info_util iu = JSON.parseObject(jsontext, info_util.class);//取得第一层JSONObjectinfo_data_util du = JSON.parseObject(iu.getData(), info_data_util.class);//取得第二层JSONObjectList<info_array_Util> olist = JSON.parseArray(du.getRows(), info_array_Util.class);//取得第三层JSONArraySystem.out.println(iu);System.out.println(du);System.out.println(olist);}

Intellij提示

解决方案

这里的data1.json应该如下放置:

FastJson_Learn/target/classes/data1.json

对应的工程结构是:

(Python3.6) appleyuchi@Desktop:~/桌面/Flink_Code/flink清洗数据案例/FastJson_Lear
n$ tree
.
├── flink.iml
├── pom.xml
├── README.md
├── src
│   └── main
│       └── java
│           ├── info_array_Util.java
│           ├── info_data_util.java
│           ├── info_util.java
│           ├── TestFastJson.java
│           ├── UserGroup.java
│           └── User.java
└── target
    ├── archive-tmp
    ├── classes
    │   ├── data1.json
    │   ├── info_array_Util.class
    │   ├── info_data_util.class
    │   ├── info_util.class
    │   ├── TestFastJson.class
    │   ├── User.class
    │   └── UserGroup.class
    └── flink-1.0-SNAPSHOT-jar-with-dependencies.jar

getResourceAsStream总是返回null以及intellij总是提示Argument ‘inputStream‘ might be null相关推荐

  1. propertysource注解 找不到文件_WinXP系统电脑开机提示windows找不到null文件的解决方法...

    WinXP系统开机提示windows找不到null文件怎么办?XP系统电脑开机提示windows找不到null文件该如何解决?请看下文具体介绍. 操作方法: 1,这是一个驱动文件,在C:Windows ...

  2. 在进行sql语句插入的时候,提示:不能将值 NULL 插入列 ‘备注‘,表 ‘Test0417.dbo.tb_举例‘;列不允许有 Null 值。INSERT 失败。

    一.概述: 在进行sql语句插入的时候,提示:不能将值 NULL 插入列 '备注',表 'Test0417.dbo.tb_举例':列不允许有 Null 值.INSERT 失败.如下所示: 二.分析 首 ...

  3. sql如何处理null值_如何正确处理SQL中的NULL值

    sql如何处理null值 前言 (Preface) A friend who has recently started learning SQL asked me about NULL values ...

  4. Warning:Null pointer access: The variable addStrings can only be null at this location

    很多小伙伴在写程序的时候对Warning不是特别看重,以为对程序没什么影响,但是花了几个小时debug之后发现错误竟然是出现在一个warning上的,顿时感觉很迷,来看下面的例子. /*** Gene ...

  5. Null pointer access: The variable xxx can only be null at this location 解决方案

    错误信息:java.lang.NullPointerException 运行前就有错误警告:Null pointer access: The variable student can only be ...

  6. null对象 java_java中当给一个对象赋值为null时发生了什么

    比如下面的代码 String[] arr = new String[10]; arr=null; 将arr这个引用置空,不指向任何对象. 上面new的那个数组对象,则没有任何引用指向它,垃圾回收器可以 ...

  7. linux gt txt内容为空,2gt;/dev/null和gt;/dev/null 2gt;amp;1和2gt;amp;1gt;/dev/null的区别...

    一.区别: 2>/dev/null 意思就是把错误输出到"黑洞" >/dev/null 2>&1 默认情况是1,也就是等同于1>/dev/null ...

  8. HashMap中最多只允许一条记录的键为Null,允许多条记录的值为Null

    Map主要用于存储健值对,根据键得到值,因此不允许键重复(重复会覆盖),但允许值重复. Hashmap是一个最常用的Map,它根据键的HashCode值存储数据,根据键可以直接获取它的值,具有很快的访 ...

  9. “SqlNullValueException: Data is Null. This method or property cannot be called on Null values.”的解决方案

    本文由 比特飞 原创发布,欢迎大家踊跃转载. 转载请注明本文地址:"SqlNullValueException: Data is Null. This method or property ...

最新文章

  1. codeforces 940D 比赛总结
  2. 代理模式和装饰者模式
  3. CTF——MISC——流量分析
  4. 区块链ppt_区块链研究(附华为百页PPT)
  5. 关于“携号转网” 还有许多你不知道的事
  6. html语义化标签_5个你可能不知道的html5语义化标签
  7. php 遍历文件夹并压成zip_php ZipArchive实现多文件打包下载实例
  8. 1010. 一元多项式求导 (25)-PAT乙级真题
  9. 光盘装系统和U盘装系统有什么区别吗?
  10. android添加工程依赖工程,将项目依赖项添加到Android studio中的另一个项目
  11. ZOJ3953 Intervals
  12. matlab的mkdir创建新的文件夹,并把图像保存在该文件夹内
  13. klwp主题大全_klwp主题包百度网盘版下载-klwp主题包百度云版 _5577安卓网
  14. 回顾RHCE——邮件收发实验
  15. 大一高数下册笔记整理_高等数学下册知识点总结.doc
  16. 从Transformer、BERT到GPT2和XLNet:高端玩家如何用论文互怼
  17. 添加Nginx ALG模块支持FTP协议ALG
  18. PDF文件怎么转换成word?
  19. 聊下git merge --squash
  20. 虚拟化系统(XenServer,ESXi)-XenServer

热门文章

  1. python3学习笔记(9)_closure
  2. CentOS7虚拟机搭建xwiki
  3. Fedora下用Iptux,中文乱码解决
  4. c# json使用集
  5. 学习scorllview
  6. 第9课_2_dbsoft安装
  7. 界限的应用开发 HTML5,更高效地到达更多设备和用户
  8. 如何将一个数据库中的一个表复制到另一个数据库中去
  9. sqlite mysql pgsql_SQLite 、MySQL 与PostgreSQL三个关系型数据库的比较
  10. 对象作为函数参数可能会导致的问题