现在的位置: 首页 > 综合 > 正文

Json lib 抛出 NestableRuntimeException

2014年09月05日 ⁄ 综合 ⁄ 共 460字 ⁄ 字号 评论关闭

JSONObject 的使用

项目中导入了 json-lib 包,但是在运行如下代码的时候还是出现了如下错误,究其原因是因为缺包,缺了如下5个包:

commons-beanutils-1.8.3

commons-lang-2.6 (注:导入最新的 3.1 版本会继续报如下错误)

commons-collections-3.2.1

commons-logging-1.1.1

ezmorph-1.0.6

Json Lib 下载:json-lib-2.4

import net.sf.json.JSONObject;

public class TestJson {
public static void main(String[] args){
Map<String, String> map = new HashMap<String, String>();
map.put("key", "value");
map.put("name", "abc");
JSONObject json = JSONObject.fromObject(map);
System.out.println(json);
}
}

抱歉!评论已关闭.