【发布时间】:2015-10-26 08:12:16
【问题描述】:
我在 JSONObject 中遇到编译错误:
构造函数 JSONObject(String) 未定义
BufferedReader br = new BufferedReader(new FileReader("json.json"));
StringBuilder sb = new StringBuilder();
String line = br.readLine();
while (line != null) {
sb.append(line);
line = br.readLine();
}
JSONObject jsonObj = new JSONObject(sb.toString());
虽然代码仅根据 JSON 文档
【问题讨论】:
-
编译错误?添加 Try-catch 异常 :)
-
你用的是什么包?
-
导入 org.json.simple.JSONArray;导入 org.json.simple.JSONObject;
-
你应该使用 import org.json.JSONException;导入 org.json.JSONObject;
标签: java json jsonobject