I'm returning some JSON from an api, and one of the child nodes of the root object is item.
I want to check whether this value at this node is null. Here's what I'm trying, which is currently throwing a JSONException when the node actually is null:
if (response.getJSONObject("item") != null) {
// do some things with the item node
} else {
// do something else
}
Logcat
07-22 19:26:00.500: W/System.err(1237): org.json.JSONException: Value null at item of type org.json.JSONObject$1 cannot be converted to JSONObject
Note that the this item node isn't just a string value, but a child object. Thank you in advance!