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

  • Home
  • SEARCH
  • 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 7782097
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T19:26:07+00:00 2026-06-01T19:26:07+00:00

I have question about parsing a specific json string. I didn’t find anything which

  • 0

I have question about parsing a specific json string. I didn’t find anything which helps me in my situation. I have this json :

{
"AM": {
    "country_name": "Armenia", 
    "data": {
        "180854": {
            "time_published": "2012-03-30 13:31:39", 
            "title": "Example", 
        }, 
        "180926": {
            "time_published": "2012-04-02 05:21:44", 
            "title": "Example", 
        }, // keeps going on
    }
},
"BM": {
    "country_name": "Bolivia", 
    "data": {
        "180854": {
            "time_published": "2012-03-30 13:31:39", 
            "title": "Example", 
        }, 
        "180926": {
            "time_published": "2012-04-02 05:21:44", 
            "title": "Industrial PPI inflation eases to 5.5% y/y in February", 
        }
    }
    }, // continues
}

So the thing that I want to know is there a way to get the value of that JSONObject : AM , BM. They are different everytime so I can’t check for them, but I want to be able to save them as String. Here is what I’m using actually to parse that JSON :

    public static void jsonParser(String jsonBuffer){

    try {

        //String jsonData = new String(jsonBuffer,"UTF-8");
        JSONObject json = (JSONObject) new JSONTokener(jsonBuffer).nextValue();


        //JSONObject country = json.getJSONObject(String.valueOf(json.keys().next()));
        Log.d("","json : "+json);
        Iterator<Object> keys = json.keys();
        while (keys.hasNext()) {
             JSONObject country = json.getJSONObject(String.valueOf(keys.next()));

            String countryName = country.getString("country_name");
            Log.e("","country_name: "+countryName);

            JSONObject data = country.getJSONObject("data");

            Iterator<Object> keys2 = data.keys();

            while(keys2.hasNext()){
                JSONObject datas = data.getJSONObject(String.valueOf(keys2.next()));

                String published = datas.getString("time_published");
                Log.d("","published : "+published);

                String title = datas.getString("title");
                Log.w("","title : "+title);
            }
        }
    } catch (JSONException e) {
        e.printStackTrace();
    }
}

So any suggestions how can I get these values?

  • 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-01T19:26:08+00:00Added an answer on June 1, 2026 at 7:26 pm

    I don’t know if I understand you correctly. You want to have “AM” and “BM” as String value, so that you have the short tag for the country name.

    The “AM” is the key you’re iterating over: keys.next()

    String short = String.valueOf(keys.next());
    JSONObject country = json.getJSONObject(short);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read few questions about parsing string by tags, but I didn't find
I have a question about type casting. I have the following JSON String: {server:clients,method:whoIs,arguments:[hello]}
i have question about YAJLiOS parser... I have next json data : {{ body
I have a question about locking. This doesn't have to be only about record
I have a question about using new[] . Imagine this: Object.SomeProperty = new[] {string1,
I have a question about XML parsing. I was experimenting with a sample program
I have a basic question about parsing expression trees. Is there a difference between
This is more of a theoretical question than a specific one. I have a
This is a high level/design type question rather than anything specific. In this game
I have question about NSView: Imagine a Custom View where the mouseDown, mouseDrag and

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.