【发布时间】:2015-12-04 21:03:34
【问题描述】:
我正在向总是有JSONArray series 并且有时有JSONArray places 的后端进行api 调用。在下面的代码中,我试图编写一个 if 语句,它说,只要没有 places 数组,就发出另一个 http 请求。但是,我没有得到一个空指针,它只是抛出一个 JSON 异常,说地方没有价值。当places 没有价值时,我可以将什么作为终止条件?我试过places == null,但没有奏效。
try{
JSONArray places = passingObject.getJSONArray("places");
JSONArray series = passingObject.getJSONArray("series");
if(some condition){
//do something else
}
}catch(JSONException e){
Log.d("JSON EXCEPTION" e.getMessage());
}
【问题讨论】:
标签: android json jsonexception