使用json的时候出现NestableRuntimeException异常
来源:互联网 发布:现代房屋设计视频软件 编辑:程序博客网 时间:2024/05/18 01:49
如果出现下面的异常:
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException
Caused by: java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException
那么可能是版本出现问题,比如用了commons-lang-3.1的最新版本3.1的,就会报上面的错误。
使用json需要导入的包为:
commons-beanutils-1.8.3
commons-lang-2.6
commons-collections-3.2.1
commons-logging-1.1.1
ezmorph-1.0.6
把json的字符串转成hashMap:
json字符串的格式大致为:{"name":"tom","age":"12"}
转化的语句:
private HashMap<String,Object> getHashMapFormJson(String jsonMsg){
JSONObject json = JSONObject.fromObject(jsonMsg);
HashMap<String,Object> result = json.toBean( json, new HashMap<String,Object>, new JsonConfig());
return result;
}
把json的字符串转成List:
json字符串的格式大致为:[{"name":"tom","age":"12"},{"name":"jack","age":"22"},........]
转化的语句:
private HashMap<String,Object> getHashMapFormJson(String jsonMsg){
JSONArray json = JSONArray.fromObject(jsonMsg);
List<HashMap<String,Object>> list = JSONArray.toList( json, new HashMap<String,Object>, new JsonConfig());
HashMap<String,Object> map1 = list.get(0);
HashMap<String,Object> map2 = list.get(1);
return map1;
}
转载的地址是:http://blog.csdn.net/wugewuge/article/details/8074272
- 使用json的时候出现NestableRuntimeException异常
- 使用JSON出现的异常
- 关于NestableRuntimeException异常的解决
- 再使用java list的时候出现空指针异常
- 下载Apk的时候出现FileNotFindException异常
- 解决比较数值时候出现的异常
- Json lib 抛出 NestableRuntimeException
- Json lib 抛出 NestableRuntimeException
- Json lib 抛出 NestableRuntimeException
- Json lib 抛出 NestableRuntimeException
- Json lib 抛出 NestableRuntimeException
- Json lib 抛出 NestableRuntimeException
- Json lib 抛出 NestableRuntimeException
- 使用Hibernate集成shiro的时候,同时使用Ehcahce出现异常
- 关于使用JSON库的时候,出现[NSCFString JSONValue]: unrecognized selector sent to instance的问题
- 关于json-lib 和hibernate一起使用的时候出现死循环的解决办法
- 关于使用JSON库的时候,出现[NSCFString JSONValue]: unrecognized selector sent to instance的问题
- 关于使用JSON库的时候,出现[NSCFString JSONValue]: unrecognized selector sent to instance的问题
- Pellet对SWRL的支持
- POJ_2485 Highway_Prim
- 身体锻炼,饮食健康,生活规律,心情愉悦
- (状态压缩) Hie with the Pie (P3311)
- 【Java TCP/IP Soket】— TCP套接字的基本使用
- 使用json的时候出现NestableRuntimeException异常
- 数据结构算法之图
- 四元数相关
- struts2 404处理
- CF 371B - Fox Dividing Cheese
- 拉丁方阵
- 《一步步写嵌入式操作系统:ARM编程的方法与实践》书中实践环境的搭建
- Linux 启动项设置
- iOS 上的蓝牙框架 - Core Bluetooth for iOS