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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T23:15:36+00:00 2026-06-16T23:15:36+00:00

I have one hashmap inside hashmap like List<Map> mapList = new ArrayList<Map>(); for (int

  • 0

I have one hashmap inside hashmap like

List<Map> mapList = new ArrayList<Map>();
    for (int i = 0; i < 2; i++) {
        Map iMap = new HashMap();
        iMap.put("Comment", "");
        iMap.put("Start", "0");
        iMap.put("Max", "0");
        iMap.put("Min", "0");
        iMap.put("Price", "5000.00");
        iMap.put("DetailsID", "51");    
        mapList.add(iMap);
    }

    Map mMap = new HashMap();
    mMap.put("ID", "27");
    mMap.put("ParticipantID", "2");
    mMap.put("ItemDetails", mapList);

I want to iterate this map and put in JSONObject for that I do

try {

    JSONObject object = new JSONObject();

    Iterator iterator = mMap.entrySet().iterator();     

    while (iterator.hasNext()) {
        Map.Entry mEntry = (Map.Entry) iterator.next();
        String key = mEntry.getKey().toString();            
        String value = mEntry.getValue().toString();
        object.put(key, value);

    }

    Log.v(TAG, "Object : " + object);

the response comes like

Object : {"ItemDetails":"[{Price=5000.00, Comment=, DetailsID=51, Min=0, Max=0, StartViolation=0}, {Price=5000.00, Comment=, DetailsID=51, Min=0, Max=0, StartViolation=0}]","ID":"27","ParticipantID":"2"}

the inner list of hashmap is not iterating

  • 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-16T23:15:37+00:00Added an answer on June 16, 2026 at 11:15 pm

    the inner list of hashmap is not iterating

    Indeed. You haven’t written any code to iterate over it. When you get the ItemDetails entry, you’ll have a key of "ItemDetails" and a value which is the list. Here’s what you’re then doing with those:

    String key = mEntry.getKey().toString();            
    String value = mEntry.getValue().toString();
    

    So you’re just calling toString() on the list. You need to work out what you really want to do. For example, you might want:

    if (mEntry.getValue() instanceof List) {
        // Handle lists here, possibly recursively
    }
    

    Note that you’ll also probably want to recurse into each Map. Again, you’ll need to write code to do this. Basically, you can’t assume that toString() is going to do what you need, which is the assumption you’re making at the moment.

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

Sidebar

Related Questions

So I have a java hashmap like below: hMap.put(1, One); hMap.put(2, Two); hMap.put(3, Two);
I have one problem HashMap<String, List<AppPrjMilestone>> dateMilestoneMap = new HashMap<String, List<AppPrjMilestone>>(); I am putting
I would like to change my qestion to the following: I have one HashMap
If I have the following declaration: Map<String, Map<String, Person>> families = Collections.synchronizedMap(new HashMap<String, Map<String,
I have one Map that contains some names and numbers Map<String,Integer> abc = new
I am getting this strange output in HashMap . I have two ArrayList<String> one
I would like to have a HashMap with only one key-value object. I have
I have a list of hashmap. One field is an Integer, and the other
Assume I have one threadpool and each thread is running following method: void runMe(HashMap
I have built a custom hashmap using two arrays. One contains keys another values.

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.