I get from the server array of objects, and by this code I convert it to json:
public static ArrayList<bussListCubic> parseBussinessArray(String result) {
ArrayList<bussListCubic> arr = new ArrayList<bussListCubic>();
try {
JSONArray jArray = new JSONArray(result);
JSONObject json_data = null;
for (int i = 0; i < jArray.length(); i++) {
json_data = jArray.getJSONObject(i);
bussListCubic userInfo = parseBussListCubic(json_data);
arr.add(userInfo);
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return arr;
}
Some times the app crashed and this is the error:
Caused by: java.lang.NullPointerException at
org.json.JSONTokener.nextCleanInternal(JSONTokener.java:116) at
org.json.JSONTokener.nextValue(JSONTokener.java:94) at
org.json.JSONArray.<init>(JSONArray.java:87) at
org.json.JSONArray.<init>(JSONArray.java:103)
it is also point that the error with this line :
JSONArray jArray = new JSONArray(result)
: line #4 in the above code...what does this error mean ?
thank you
null
, and you're trying to use that object as if it wasn't.