Home:ALL Converter>How to get JSON data from php webservice : "no value for data" error

How to get JSON data from php webservice : "no value for data" error

Ask Time:2012-09-22T17:01:23         Author:VKSingh

Json Formatter

I am new to the Android Platform and I want to fetch value's from a PHP Web Service through JSON Parser. But I am not getting the data, rather the error: No value for data25 ,data26 and data27.

I appreciate any help sorting out this problem.

try{
            JSONArray jArray = new JSONArray(result);
            for(int i=0;i<jArray.length();i++)
            {
            HashMap<String, String> map = new HashMap<String, String>();

              JSONObject json_data = jArray.getJSONObject(i);

            map.put("data25", "date25:" + json_data.getString("data25"));
            map.put("data26", "data26:" + json_data.getString("data26"));
            map.put("data27", "data27:" + json_data.getString("data27"));

            mylist.add(map);

            }

The JSON result is as follows:

[
{
    "data1": "5794",
    "data2": "2922",
    "data3": "6799",
    "data4": "2729",
    "data5": "9860",
    "data6": "4486",
    "data7": "9903",
    "data8": "0113",
    "data9": "9936",
    "data10": "5470",
    "data11": "7423",
    "data12": "1237",
    "data13": "6564",
    "data14": "1261",
    "data15": "4730",
    "data16": "7714",
    "data17": "2410",
    "data18": "7486",
    "data19": "7046",
    "data20": "8263",
    "data21": "4305",
    "data22": "6244",
    "data23": "2495",
    "data24": " 19\/09\/2012(Wed)"
},
{
    "data1": "555",
    "data2": "039",
    "data3": "353",
    "data4": "1438",
    "data5": "8720",
    "data6": "7490",
    "data7": "1294",
    "data8": "4000",
    "data9": "6017",
    "data10": "2294",
    "data11": "4042",
    "data12": "0064",
    "data13": "8441",
    "data14": "1252",
    "data15": "9609",
    "data16": "0797",
    "data17": "1680",
    "data18": "0917",
    "data19": "7492",
    "data20": "9488",
    "data21": "3253",
    "data22": "7915",
    "data23": "1071",
    "data24": " 19\/09\/2012(Wed)",
    //--heredata25,
    data26,
    data27----------"data25": "9555",
    "data26": "3039",
    "data27": "6353"
},
{
    "data1": "0395",
    "data2": "5928",
    "data3": "8998",
    "data4": "6447",
    "data5": "1827",
    "data6": "8131",
    "data7": "7454",
    "data8": "4647",
    "data9": "1892",
    "data10": "3656",
    "data11": "1989",
    "data12": "9095",
    "data13": "6826",
    "data14": "1860",
    "data15": "9766",
    "data16": "6069",
    "data17": "6050",
    "data18": "6526",
    "data19": "8392",
    "data20": "0520",
    "data21": "7540",
    "data22": "3608",
    "data23": "7430",
    "data24": " 19\/09\/2012(Wed)"
},

Author:VKSingh,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/12542387/how-to-get-json-data-from-php-webservice-no-value-for-data-error
yy