net.sf.json.JSONException: JSONObject["solution"] not found.

没有这个元素造成的。
  问题代码:

  1. JSONObject json = smArr.getJSONObject(i);
  2. json.getString("solution");

分析原因:

  json中没有这个key,更没有这个key所对应的值

解决办法:判断一下是否有这个key,没有就加入,并添加所对应的值""

  1. f (!json.has("solution")){
  2. json.put("solution", "");
  3. }

Json_异常_net.sf.json.JSONException: JSONObject["solution"] not found.的更多相关文章

  1. json解析异常 - net.sf.json.JSONException: java.lang.reflect.InvocationTargetException

    注:在项目中, 我使用原生的ajax请求数据的时候, JSONObject没能帮我解析, 当却不给我报错, 我是在junit单元测试中测试的时候, 发现的.发现好多时候, 特别是通过ajax请求, 不 ...

  2. json数据转换异常:net.sf.json.JSONException: java.lang.reflect.InvocationTargetException

    转:json数据转换异常:net.sf.json.JSONException: java.lang.reflect.InvocationTargetException 执行:JSONArray arr ...

  3. net.sf.json.JSONException: There is a cycle in the hierarchy!

    因为项目中使用了AJAX技术,jar包为:json-lib.jar,在开发过程中遇到了一个JSON-LIB和Hibernate有关的问题: 如hibernate延迟加载错误,这都是些老问题了,一看就知 ...

  4. net.sf.json.JSONException: There is a cycle in the hierarchy!错误解决方案

    net.sf.json.JSONException: There is a cycle in the hierarchy!错误解决方案 今天在用List集合转换成json数组的时候发生了这个错误,这个 ...

  5. 前后台JSON传值得一个问题和异常处理net.sf.json.JSONException: Unquotted string '"name"'

    项目中做导入的时候遇到个bug,用JSON.stringify()序列号json对象传给后台:然后后台通过getPatameter()获取值时,前台的英文引号变成了中文引号. 原来代码如下:(自己排查 ...

  6. atitit.解决net.sf.json.JSONException There is a cycle in the hierarchy

    atitit.解决net.sf.json.JSONException There is a cycle in the hierarchy 1. 环境:使用hibernate4跟个,,要不个哪的对象系列 ...

  7. net.sf.json.JSONException: java.lang.NoSuchMethodException

    在尝试将json对象转换为list时候出现了如下错误 Exception in thread "main" net.sf.json.JSONException: java.lang ...

  8. XML2JSON 的【net.sf.json.JSONException: nu.xom.ParsingException must be followed by either attribute specifications, ">" or "/>"】问题解决办法

    在使用JSon-Lib库进行XML2JSon的转换时,在JUnit测试时没有什么问题,但是在Tomcat里面跑的时候,抛出了下面的异常,查找了google,发现关于这方便的文章比较少,即使有,也需要F ...

  9. java.sql.Date赋值给了java.util.Date.转化成JSONArray时出错net.sf.json.JSONException: java.lang.reflect.InvocationTargetException

    net.sf.json.JSONException: java.lang.reflect.InvocationTargetExceptionat net.sf.json.JSONObject.defa ...

随机推荐

  1. spring异常-aoperror at :0 formal unbound in pointcut

    八月 17, 2016 10:15:21 上午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRe ...

  2. Python for Informatics 第11章 正则表达式六(译)

    注:文章原文为Dr. Charles Severance 的 <Python for Informatics>.文中代码用3.4版改写,并在本机测试通过. 11.7 调试 Python有一 ...

  3. MySQL-多条件拼接语句

    BEGIN "; SET @_where=""; THEN SET @_where= CONCAT(@_where," AND sourcedomain=\&q ...

  4. C#生成二维码的方法

    本文实例讲述了C#生成二维码的方法.分享给大家供大家参考.具体实现方法如下: 首先引用ThoughtWorks.QRCode.dll 具体代码如下: 复制代码 代码如下: using System; ...

  5. Spring注入方式及注解配置

    一:基于xml的DI(Dependency Injection) 注入类型: 定义学生Student实体类和小汽车Car实体类:进行封装和生成ToString(),并自定义属性Car Student ...

  6. scala and machine learning

    http://download.csdn.net/album/detail/3376 scala and machine learning

  7. 2016huasacm暑假集训训练四 DP_B

    题目链接:http://acm.hust.edu.cn/vjudge/contest/125308#problem/M 题意:有N件物品和一个容量为V的背包.第i件物品的费用是体积c[i],价值是w[ ...

  8. MySql存储过程的操作

    [存储过程1] 写一个存储过程 procedure实现两数相加 DELIMITER && CREATE PROCEDURE pr_add(xx INT,yy INT) BEGIN DE ...

  9. php进程占用大量cpu优化

    使用TOP 命令发现php进程占用大量的cpu,达到100%,需要优化. 1 ll /proc/6264/fd 查看进程正在使用的资源 2 strace -p 6264 追踪进程正在做的事情 引用 h ...

  10. [dpdk] 熟悉SDK与初步使用 (四)(L3 Forwarding源码分析)

    接续前节:[dpdk] 熟悉SDK与初步使用 (三)(IP Fragmentation源码分析) 前文中的最后一个问题,搁置,并没有找到答案.所以继续阅读其他例子的代码,想必定能在其他位置看到答案. ...