谁能帮助我理解出了什么问题?
unreported exception org.json.JSONException; must be caught or declared to be thrown
jsonObj = new JSONObject("{\"count\":3939,\"has_more\":true,\"map_location\":{\"lat\":0.60996950000000183,\"lon\":-27.568517000000003,\"panoramio_zoom\":16},\"photos\":[{\"height\":375,}]}"); //creates the JSON object from the jsonString, for parsing
^
1 error
我正在使用 org.json,并且我认为我已正确设置所有内容。我试图使用 org.json 中接受源字符串的构造函数创建一个 JSONObject,但我不断收到此异常。我不确定我发送的字符串有什么问题。谢谢
通过创建 try 和 catch 来捕获异常:
try {
JSONObject jsonObj = new JSONObject("{\"count\":3939,\"has_more\":true,\"map_location\":{\"lat\":0.60996950000000183,\"lon\":-27.568517000000003,\"panoramio_zoom\":16},\"photos\":[{\"height\":375,}]}");
System.out.println(jsonObj);
} catch (JSONException e) {
//some exception handler code.
}
或者向调用者方法抛出异常:
public String yourMethod(String jsonString) throws JSONException
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)