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
The crash is caused by an invalid String result
print the result passed to parseBussinessArray
method and see what is its value when crash happens
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.