org.json.JSONException: JSONObject["shophours"] not found.
没有这个元素造成的。
问题代码:
value = jsonObject.get(entry).toString();
分析原因:
json中没有这个key,更没有这个key所对应的值
解决办法:判断一下是否有这个key,没有就加入,并添加所对应的值
if(!jsonObject.has(entry)){
value = "null";
}
else {
value = jsonObject.get(entry).toString();
}
org.json.JSONException: JSONObject["shophours"] not found.的更多相关文章
- Json_异常_net.sf.json.JSONException: JSONObject["solution"] not found.
net.sf.json.JSONException: JSONObject["solution"] not found. 没有这个元素造成的. 问题代码: JSONObject j ...
- 大话 JSON 之 JSONObject.getString(“”) 方法 和 JSONObject.optString(“”) 的区别
运行以下代码: public static void main(String[] args) { JSONObject test = new JSONObject(); test.put(" ...
- grails框架中读取txt文件内容将内容转换为json格式,出现异常Exception in thread "main" org.json.JSONException: A JSONObject text must begin with '{' at character 1 of [...]
Exception in thread "main" org.json.JSONException: A JSONObject text must begin with '{' a ...
- new JSONObject(str)无法解析 报错:org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject
org.json.JSONException: Value of type java.lang.String cannot be converted to JSONObject 解析服务器返回的Jso ...
- org.json.JSONException: A JSONObject text must begin with '{' at character 1 of {解决方法
在使用java读取一个本地的json配置文件的时候,产生了这个异常:org.json.JSONException: A JSONObject text must begin with '{' at c ...
- json数据格式 net.sf.json.JSONException: A JSONObject text must begin with '{' at character 1 of Error:(findColumns1)Read timed out
substring(3)的用法http://www.w3school.com.cn/jsref/jsref_substring.asp 可能一:sb是要转化的数据,以sb是String为例 ...
- bug_ _org.json.JSONException: End of input at character 0 of
10-16 18:28:39.549: W/System.err(4950): org.json.JSONException: End of input at character 0 of 10-16 ...
- 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跟个,,要不个哪的对象系列 ...
- net.sf.json.JSONException: java.lang.NoSuchMethodException
在尝试将json对象转换为list时候出现了如下错误 Exception in thread "main" net.sf.json.JSONException: java.lang ...
随机推荐
- 【做题】arc070_f-HonestOrUnkind——交互+巧妙思维
做的第一道交互题-- 首先,有解的一个必要条件是\(a>b\).否则,即当\(a<=b\)时,可以有\(a\)个unkind的人假装自己就是那\(a\)个honest的人.(彼此之间都说是 ...
- 【做题】cf603E——线段树分治
首先感谢题解小哥,他在标算外又总结了三种做法. 此处仅提及最后一种做法. 首先考虑题目中要求的所有结点度数为奇数的限制. 对于每一个联通块,因为所有结点总度数是偶数,所以总结点数也必须是偶数的.即所有 ...
- 【Finchley】【升级变更】Spring Cloud 升级到Finchley版本后需要注意的地方
Spring Boot 2.x 已经发布了很久,现在 Spring Cloud 也发布了 基于 Spring Boot 2.x 的 Finchley 版本,现在一起为项目做一次整体框架升级. 升级前 ...
- P2617 Dynamic Rankings(带修主席树)
所谓带修主席树,就是用树状数组的方法维护主席树的前缀和 思路 带修主席树的板子 注意数据范围显然要离散化即可 代码 #include <cstdio> #include <cstri ...
- Unity3D代码动态修改材质球的颜色
代码动态修改材质球的颜色: gameObject.GetComponent<Renderer>().material.color=Color.red;//当材质球的Shader为标准时,可 ...
- MongoDB 基本语法笔记
MongoDB常识 MongoDB Shell是MongoDB自带的交互式Javascript shell,所以可直接执行JS脚本,用来对MongoDB进行操作和管理的交互式环境. ObjectId: ...
- Kubernetes之Controllers一
ReplicaSet is the next-generation Replication Controller. The only difference between a ReplicaSet a ...
- EFI环境下的Ubuntu&Win10双系统安装
因为是win10是EFI启动的,所以网上的easyBCD方法就不可以用了,这里用到的不是ultraiso软碟通,用的哪个忘了 不过只要能写入U盘做成启动盘就ok 具体参考的是https://blog. ...
- PHP feof()函数
feof()函数检查是否已经到达文件末尾(EOF) EOF == end of file 如果出错或者文件指针到了文件末尾(EOF)则返回true,否则返回false 语法: feof(file) ...
- Python open 对应的参数