Android中Volley的JSON解析问题?

时间:2019-03-21 06:59:28

标签: android broadcastreceiver android-volley android-json

该项目以前曾经成功工作过。将URL的{​​{1}}更改为不解析数据之后。我们更改了网址web service而不是bus/search。     这是我发送请求的地方,它使用新URL成功运行。但是这种状态有效,并显示此故障。

bus
  

错误:e:“ org.json.JSONException:状态无值

Voyage.java

 catch (JSONException e) {
  Log.e("search" + owner + "VoyagesErr1", e.toString());
  e.printStackTrace();  
}

这堂课没有收到。

 private void sendRequest(final String owner, final Map<String, String> header) {
    //url = "http://12.1.1.12:1337/";
    StringRequest stringRequest = new StringRequest(Request.Method.POST, MyConstants.URL + owner,
            new Response.Listener<String>() {
                @Override
                // servisten 200 olarak bir veri alındığında onResponse içine düşüyor.
                public void onResponse(String response) {

                 //   Log.e("AAAA" + owner, response);
                    try {
                        JSONObject object = new JSONObject(response);
                        if (object.getString(MyConstants.SERVICE_STATUS).equals(MyConstants.SERVICE_RESPONSE_STATUS_NOTAVAILABLE)) {
                            sendVoyagesErrorBroadcast(owner, MyConstants.ERROR_NOTAVAILABLE);
                        } else if (object.getString(MyConstants.SERVICE_STATUS).equals(MyConstants.SERVICE_RESPONSE_STATUS_SUCCESS)) {
                            JSONArray result = object.getJSONArray(MyConstants.SERVICE_RESULT);
                            JSONArray resultGoing = result.getJSONObject(0).getJSONArray("going");
                            if (has_return) {
                                JSONArray resultReturn = result.getJSONObject(1).getJSONArray("round");
                                sendVoyagesArrayBroadcast(owner + MyConstants.DIRECTION_RETURN, resultReturn);
                            }
                            sendVoyagesArrayBroadcast(owner + MyConstants.DIRECTION_GOING, resultGoing);
                        } else if (object.getString(MyConstants.SERVICE_STATUS).equals(MyConstants.SERVICE_RESPONSE_STATUS_FAİLURE)) {
                            sendVoyagesErrorBroadcast(owner, MyConstants.ERROR_SERVER);
                        }
                    } catch (JSONException e) {
                        Log.e("search" + owner + "VoyagesErr1", e.toString());
                        e.printStackTrace();
                    }
                }
            }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {

            Log.e("AAAA" + owner, String.valueOf(error.getCause()));
            sendVoyagesErrorBroadcast(owner, getErrorType(error));
        }

0 个答案:

没有答案