Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/189.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
E/JSON ;解析器:解析数据时出错[java.lang.Integer类型的值60无法转换为JSONObject]60(97)_Java_Android_Mysql_Json - Fatal编程技术网

E/JSON ;解析器:解析数据时出错[java.lang.Integer类型的值60无法转换为JSONObject]60(97)

E/JSON ;解析器:解析数据时出错[java.lang.Integer类型的值60无法转换为JSONObject]60(97),java,android,mysql,json,Java,Android,Mysql,Json,我是android编程新手。当我试图使用JSON从android中的mysql数据库获取数据时,我遇到了一个问题。这是我的方法。这是我收到的错误:java.lang.Integer类型的值60无法转换为JSONObject private void getData(final String mac_Address){ //Creating a string request // Tag used to cancel the request String tag_strin

我是android编程新手。当我试图使用JSON从android中的mysql数据库获取数据时,我遇到了一个问题。这是我的方法。这是我收到的错误:java.lang.Integer类型的值60无法转换为JSONObject

private void getData(final String mac_Address){
    //Creating a string request
    // Tag used to cancel the request
    String tag_string_req = "req_monitor";
    StringRequest stringRequest = new StringRequest(Request.Method.POST, AppConfig.URL_MONITOR_HEALTH_PARAMETERS,
            new Response.Listener<String>() {
                @Override
                public void onResponse(String response) {
                    JSONObject j = null;
                    try {

                        //Parsing the fetched Json String to JSON Object
                        j = new JSONObject(response);
                        //boolean error = j.getBoolean("error");

                        //j = new JSONObject().append("userid", new JSONArray(json).getInt(0));
                        //boolean error = j.getBoolean("error");
                        //return new JSONObject(json.substring(json.indexOf("{"), json.lastIndexOf("}") + 1));

                        //Storing the Array of JSON String to our JSON Array
                        result = j.getJSONArray("result");
                        //new JSONObject().append("pulse_rate", new JSONArray(result).getInt(0));
                        //JSONArray k = null;
                        for(int i=0;i<result.length();i++){
                            try {
                                //Getting json object
                                JSONObject json = result.getJSONObject(i);

                                pulse_rate.add(json.getInt("pulse_rate"));
                                pulse_oxygen_saturation.add(json.getInt("pulse_oxygen_saturation"));
                                Log.d(TAG, "Fetching pulse rate from mysql: " +pulse_rate+" Fetching pulse rate from mysql: "+pulse_oxygen_saturation);
                            } catch (JSONException e) {
                                e.printStackTrace();
                            }
                        }

                        //Calling method getMonitoringData to get the students from the JSON Array
                       // getMonitoringData(result);
                    } catch (JSONException e) {
                        e.printStackTrace();
                        Log.e("JSON Parser", "Error parsing data [" + e.getMessage()+"] "+response);
                    }
                }
            },
            new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError error) {

                }

            })
    {

        @Override
        protected Map<String, String> getParams() {
            // Posting parameters to monitor url
            Map<String, String> params = new HashMap<String, String>();
            params.put("mac_Address", mac_Address);
            return params;
        }

    };

    //Creating a request queue
    //RequestQueue requestQueue = Volley.newRequestQueue(this);

    // Adding request to request queue
    AppController.getInstance().addToRequestQueue(stringRequest, tag_string_req);

    //Adding request to the queue
    //requestQueue.add(stringRequest);

}
 {
"result": [{
    "pulse_rate": "60",
    "pulse_oxygen_saturation": "97"
}, {
    "pulse_rate": "60",
    "pulse_oxygen_saturation": "97"
}, {
    "pulse_rate": "59",
    "pulse_oxygen_saturation": "97"
}, {
    "pulse_rate": "59",
    "pulse_oxygen_saturation": "98"
}, {
    "pulse_rate": "58",
    "pulse_oxygen_saturation": "98"
}, {
    "pulse_rate": "59",
    "pulse_oxygen_saturation": "98"
}, {
    "pulse_rate": "59",
    "pulse_oxygen_saturation": "98"
}, {
    "pulse_rate": "58",
    "pulse_oxygen_saturation": "98"
}, {
    "pulse_rate": "58",
    "pulse_oxygen_saturation": "98"
}, {
    "pulse_rate": "255",
    "pulse_oxygen_saturation": "127"
}, {
    "pulse_rate": "70",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "69",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "67",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "66",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "64",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "63",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "64",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "63",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "62",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "63",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "64",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "63",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "62",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "63",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "62",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "61",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "60",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "61",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "63",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "64",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "65",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "64",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "65",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "66",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "67",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "66",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "65",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "64",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "255",
    "pulse_oxygen_saturation": "127"
}, {
    "pulse_rate": "72",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "73",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "71",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "65",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "62",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "60",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "59",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "60",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "60",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "255",
    "pulse_oxygen_saturation": "127"
}, {
    "pulse_rate": "66",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "63",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "62",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "61",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "60",
    "pulse_oxygen_saturation": "99"
}]
}
这是我日志中的JSON响应: 这是我日志中的内容:

 {
"result": [{
    "pulse_rate": "60",
    "pulse_oxygen_saturation": "97"
}, {
    "pulse_rate": "60",
    "pulse_oxygen_saturation": "97"
}, {
    "pulse_rate": "59",
    "pulse_oxygen_saturation": "97"
}, {
    "pulse_rate": "59",
    "pulse_oxygen_saturation": "98"
}, {
    "pulse_rate": "58",
    "pulse_oxygen_saturation": "98"
}, {
    "pulse_rate": "59",
    "pulse_oxygen_saturation": "98"
}, {
    "pulse_rate": "59",
    "pulse_oxygen_saturation": "98"
}, {
    "pulse_rate": "58",
    "pulse_oxygen_saturation": "98"
}, {
    "pulse_rate": "58",
    "pulse_oxygen_saturation": "98"
}, {
    "pulse_rate": "255",
    "pulse_oxygen_saturation": "127"
}, {
    "pulse_rate": "70",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "69",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "67",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "66",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "64",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "63",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "64",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "63",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "62",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "63",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "64",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "63",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "62",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "63",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "62",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "61",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "60",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "61",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "63",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "64",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "65",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "64",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "65",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "66",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "67",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "66",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "65",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "64",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "255",
    "pulse_oxygen_saturation": "127"
}, {
    "pulse_rate": "72",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "73",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "71",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "65",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "62",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "60",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "59",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "60",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "60",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "255",
    "pulse_oxygen_saturation": "127"
}, {
    "pulse_rate": "66",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "63",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "62",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "61",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "60",
    "pulse_oxygen_saturation": "99"
}]
}
试试这个

 {
"result": [{
    "pulse_rate": "60",
    "pulse_oxygen_saturation": "97"
}, {
    "pulse_rate": "60",
    "pulse_oxygen_saturation": "97"
}, {
    "pulse_rate": "59",
    "pulse_oxygen_saturation": "97"
}, {
    "pulse_rate": "59",
    "pulse_oxygen_saturation": "98"
}, {
    "pulse_rate": "58",
    "pulse_oxygen_saturation": "98"
}, {
    "pulse_rate": "59",
    "pulse_oxygen_saturation": "98"
}, {
    "pulse_rate": "59",
    "pulse_oxygen_saturation": "98"
}, {
    "pulse_rate": "58",
    "pulse_oxygen_saturation": "98"
}, {
    "pulse_rate": "58",
    "pulse_oxygen_saturation": "98"
}, {
    "pulse_rate": "255",
    "pulse_oxygen_saturation": "127"
}, {
    "pulse_rate": "70",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "69",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "67",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "66",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "64",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "63",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "64",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "63",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "62",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "63",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "64",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "63",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "62",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "63",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "62",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "61",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "60",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "61",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "63",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "64",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "65",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "64",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "65",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "66",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "67",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "66",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "65",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "64",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "255",
    "pulse_oxygen_saturation": "127"
}, {
    "pulse_rate": "72",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "73",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "71",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "65",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "62",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "60",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "59",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "60",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "60",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "255",
    "pulse_oxygen_saturation": "127"
}, {
    "pulse_rate": "66",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "63",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "62",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "61",
    "pulse_oxygen_saturation": "99"
}, {
    "pulse_rate": "60",
    "pulse_oxygen_saturation": "99"
}]
}
pulse_rate.add(json.getString("pulse_rate"));
                            pulse_oxygen_saturation.add(json.getString("pulse_oxygen_saturation"));

请发布您的json回复。您的json响应和解析它的方式似乎有些不同。{“结果”:[{“脉搏率”:“60”,“脉搏血氧饱和度”:“97}]}60(97){“结果”:[{“脉搏率”:“60”,“脉搏血氧饱和度”:“97},{“脉搏率”:“60”,“脉搏血氧饱和度”:“97}]}59(97)它看起来不像一个有效的json。请发布正确有效的JSON响应。我已经发布了。或者可能是我的php脚本有问题,它绝对不是有效的JSON。转到jsonlint.com并验证它,您可以看到问题。我收到了这个错误:java.lang.NullPointerException pulse_rate.add(json.getInt(“pulse_rate”);