我想在java中接收JSONArray,但它总是给我一个空指针异常。 我通过php
发送带有2d数组的Response这是我的PHP代码:
$this->arr = array(array("Max" , 1 , true) , array("Adam" , 2 , false));
$response = new JsonResponse();
$response->setdata($this->arr);
$response->setStatusCode(200);
return $response;
这就是我在java中编写的代码:
String link = Config.API_BASE_URL + "/" + loggedInId + "/notifications";
GetRequest request = new GetRequest(link) {
@Override
protected void onPostExecute(String response) {
if (this.getStatusCode() == 200) {
try {
JSONArray json = new JSONArray(response);
viewNotifications(json);
//viewNotificationsTest();
} catch (JSONException e) {
e.printStackTrace();
}
}