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 9171467
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:10:00+00:00 2026-06-17T16:10:00+00:00

I want to retrieve the values of all element in this json format document.

  • 0

I want to retrieve the values of all element in this json format document.

[
            {
                "id": "c0001xgp",
                "title": 8.8,
                "content": 142.369,
                "vignette": "us",
                "image": "2011-03-11 04:46:23",
                "type": 24.4,
                "pubdate": 38.322
          },
            {
                "id": "c0001xgp",
                "title": 8.8,
                "content": 142.369,
                "vignette": "us",
                "image": "2011-03-11 04:46:23",
                "type": 24.4,
                "pubdate": 38.322
          },  {
                "id": "c0001xgp",
                "title": 8.8,
                "content": 142.369,
                "vignette": "us",
                "image": "2011-03-11 04:46:23",
                "type": 24.4,
                "pubdate": 38.322
          },  {
                "id": "c0001xgp",
                "title": 8.8,
                "content": 142.369,
                "vignette": "us",
                "image": "2011-03-11 04:46:23",
                "type": 24.4,
                "pubdate": 38.322
          }

]

how can i achieve this. i’m learning json and android. when there is a parent in the json object i can deal with but now i am have trouble to solve this problem.

The main class

// JSON Node names
private static final String TAG_ARRAY= "";

private static final String TAG_ID = "id";

private static final String TAG_TITLE = "title";

private static final String TAG_CONTENT = "content";

private static final String TAG_VIGNETTE = "vignette";

private static final String TAG_IMAGE = "image";

private static final String TAG_TYPE = "type";

private static final String TAG_PUBDATE = "pubdate";


// contacts JSONArray

JSONArray myArray = null;

@Override

public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.actus);

    // Hashmap for ListView
    ArrayList<HashMap<String, String>> contactList = new ArrayList<HashMap<String, String>>();

    // Creating JSON Parser instance

    JSONParser jParser = new JSONParser();

    // getting JSON string from URL
     JSONArray jArray = jParser.getJSONFromUrl(url);


        // looping through All element
        for(int i = 0; i < jArray.length(); i++){


            JSONObject oneObject = null;
            try{

            oneObject = jArray.getJSONObject(i);

            // Storing each json item in variable
            String id;

            String title;

                title = oneObject.getString(TAG_TITLE);


            String content = oneObject.getString(TAG_CONTENT);

            String vignette = oneObject.getString(TAG_VIGNETTE);

            String image = oneObject.getString(TAG_IMAGE);

            String type = oneObject.getString(TAG_TYPE);

            String pubdate = oneObject.getString(TAG_PUBDATE);


            // creating new HashMap
            HashMap<String, String> map = new HashMap<String, String>();

            // adding each child node to HashMap key => value

            map.put(TAG_TITLE, title);

            map.put(TAG_CONTENT, content);

            map.put(TAG_VIGNETTE, vignette);

            map.put(TAG_TYPE, type);

            map.put(TAG_PUBDATE, pubdate);



            // adding HashList to ArrayList

            contactList.add(map);


            }catch (JSONException e) {

                // TODO Auto-generated catch 

block
e.printStackTrace();
}

        }



    /**
     * Updating parsed JSON data into ListView
     */
    ListAdapter adapter = new SimpleAdapter(this, contactList,
            R.layout.list_item,
            new String[] { TAG_TITLE, TAG_CONTENT, TAG_VIGNETTE }, new int[] {
                    R.id.name, R.id.email, R.id.mobile });

    setListAdapter(adapter);

    // selecting single ListView item
    ListView lv = getListView();

    // Launching new screen on Selecting Single ListItem

    lv.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view,
                int position, long id) {
            // getting values from selected ListItem
            String name = ((TextView) view.findViewById(R.id.name)).getText().toString();

            String cost = ((TextView) view.findViewById(R.id.email)).getText().toString();

            String description = ((TextView) view.findViewById(R.id.mobile)).getText().toString();

            // Starting new intent
            Intent in = new Intent(getApplicationContext(), SingleMenuItemActivity.class);
            in.putExtra(TAG_VIGNETTE, name);

            in.putExtra(TAG_CONTENT, cost);

            in.putExtra(TAG_VIGNETTE, description);

            startActivity(in);

        }
    });


}
  • 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-17T16:10:01+00:00Added an answer on June 17, 2026 at 4:10 pm

    parse current json String as to get all values from json Object :

    JSONArray jArray = new JSONArray("your json String");
    
    for (int i=0; i < jArray.length(); i++)
    {
      JSONObject oneObject = jArray.getJSONObject(i);
       // get all value here
       String str_eqid=oneObject.getString("eqid");
       String str_magnitude=oneObject.getString("magnitude");
       String str_lng=oneObject.getString("lng");
       String str_src=oneObject.getString("src");
    
        // get other values from jsonobject in same way
    }
    

    and use ArrayList and HashMap for Storing values

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a HTML table as follows. I want retrieve row values from this
I want to store values and retrieve them from a Java HashMap. This is
I want to retrieve attribute values of all rows present in my table.and i
I want to retrieve values from SQLite database in my Android application. Here in
i am using coredata in my application to store and retrieve values.i want to
i want to retrieve certificate information e.g, Issued to, Issued by values of a
What I want retrieve task whch due element is overdue. What the XML is
I have simple redis list key => supplier_id Now all I want it retrieve
I have a problem when trying to retrieve values from an array. I want
I am trying to retrieve values from a json api and displaying then in

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.