解析JSON时出现齐射错误

时间:2016-04-29 18:50:29

标签: java android android-volley

从REST服务器收到响应时出错。我发现很少有相同问题的主题,但仍无法找到解决方案。这是我的代码

public void clickFunc(View v){
    String url = "http://localhost:8080/Server/file/04";
    final CustomJSONObjectRequest jsonRequest = new CustomJSONObjectRequest(Request.Method.GET, url, new JSONObject(), this, this);
    jsonRequest.setTag(REQUEST_TAG);
    mQueue.add(jsonRequest);
}

@Override
public void onErrorResponse(VolleyError error) {
    //  mTextView.setText(error.getMessage());
    Log.i("test","error "+error.getMessage());
}

@Override
public void onResponse(Object response) {
    // mTextView.setText("Response is: " + response);
    //  mTextView.setText(mTextView.getText() + "\n\n" + ((JSONObject) response).getString ("name"));
    Log.i("test","ok");
    // Log.i("test",response.toString());
}

错误是

type org.json.JSONArray cannot be converted to JSONObject

我试图以这种方式更改响应功能

public void onResponse(JSONArray response)

但是我收到一个错误:方法不会覆盖...

0 个答案:

没有答案