Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8568849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:12:04+00:00 2026-06-11T18:12:04+00:00

I am new to the Android Platform and I want to fetch value’s from

  • 0

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)"
},
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T18:12:05+00:00Added an answer on June 11, 2026 at 6:12 pm

    As per the response you have posted, it is a JSONArray of JSONObjects. Each JSONObject contains the values with the keys like data1, data2…etch. But every JSONObject doesn’t contain the keys data25, data26, data27. If you don’t want to throw exception even the response does n’t contain the data25,data26, data27 keys in every JSONObject then you need to modify the code like below:

            JSONArray jArray = new JSONArray(result);
            for(int i=0;i<jArray.length();i++)
            {
            HashMap<String, String> map = new HashMap<String, String>();
    
              // getJSONObject() will throw exception if the key is not found in the jsonObject. Instead of it use optJSONObject() to get the values from JSONObject. It returns the value if contains otherwise returns the empty jsonObject.
              // JSONObject json_data = jArray.getJSONObject(i);
              JSONObject json_data = jArray.optJSONObject(i);
    
    
            //map.put("data25", "date25:" + json_data.getString("data25"));
             map.put("data25", "date25:" + json_data.optString("data25")); // returns empty string on not finding the key in JSONObject.
    
            //map.put("data26", "data26:" + json_data.getString("data26"));
            //map.put("data27", "data27:" + json_data.getString("data27"));
    
            mylist.add(map);
    
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know this has been covered elsewhere, but I'm new to the Android platform
I want to learn a new programming language and develop for the Android platform.
I am new in android and working on titanium platform but not getting how
I am using Android 3.1 platform and i just want to create new contact
I want to develop a application on Android platform to connect to salesforce. From
I am new to android platform. I want to develop android application with Google
I'm building a new application to the Android platform and I want to implement
when i am creating new android project from visual studio 2010 it gives the
I am a new android app developer and i want to use google map
I am new android app developer i want make app for tablets and phone

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.