2017-04-07 61 views
0

我得到JSON响应,处理空

["L500","Success",null] 

我如何处理它

这里是我试过

jsonArray.getJSONArray(2).getJSONObject(2).equals(JSONObject.NULL); 

然而,它产生的错误:

org.json.JSONException: Value null at 2 of type org.json.JSONObject$1 cannot be converted to JSONArray

如果为空,我需要显示一个给用户Toast消息,如“没有找到记录”。

+0

有什么问题你目前的做法取代

jsonArray.getJSONArray(2).getJSONObject(2).equals(JSONObject.NULL); 

解决它?它做什么,它应该做什么? – Rob

+0

获取org.json.JSONException:在类型为org.json.JSONObject $ 1的2处的值null不能转换为JSONArray – Andi

回答

1

我用

jsonArray.get(2).equals(null);