How to handle null response for json object
Posted
by
user1494754
on Stack Overflow
See other posts from Stack Overflow
or by user1494754
Published on 2012-12-05T19:50:46Z
Indexed on
2012/12/06
11:05 UTC
Read the original article
Hit count: 188
I get a JSON response as
{
"edges": [],
"nodes": []
}
how to check if the objects has null values and handle the case??
JSONObject jobj = new JSONObject(line);
JSONArray jArray = jobj.getJSONArray("edges");
if(jArray.length()!=0)
{
for(int i=0;i<jArray.length();i++){
JSONObject json_data = jArray.getJSONObject(i);
x.add((float) json_data.getInt("x"));
y.add((float) json_data.getInt("y"));
end
This retrurns me : org.json.JSONException: end of input at character 0 of
© Stack Overflow or respective owner