Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

JAVA, EntrySet(), iterator

  1. Feb 26, 2014 #1
    Using the following code:

    Code (Text):
    Set<Map.Entry<String,JsonElement>> mySet = jsonObject.entrySet();
    for(Map.Entry<String,JsonElement> singleItem : mySet)
    {
        singleItem.getKey();
        System.out.println("Set values: " + mySet);
    }
    mySet gets printed to the console as:

    Code (Text):
    Set values: [columnGridContainer="[[1,\"1\",\"Default Value\",\"Y\",\"N\",\"0\",\"Left\",\"Default Value\",\"Default Value\",\"Default Value\",\"Default Value\",\"Left\",\"Center\",\"Center\",\"Center\",\"#000056\",\"None\",\"Date/Time\",\"No Filter\",\"N\"]]", header_row_2_enabled="Y", header_row_3_enabled="Y", header_row_4_enabled="Y", col_widths_units="pixels", default_sub_rows_closed="Y", extjs_component="grid", refreshrate="181", title="everything works right", subtitle="except display for checkboxes....", autoheight="N", bottom_buttons="N", col_label_source="col_config_table"]
    I need to iterate through the values and put them into an array. Please provide some direction as to how to iterate over this mapped entrySet and enter each value into an array.
     
  2. jcsd
  3. Mar 2, 2014 #2
    You are printing out the whole set in your for loop, don't you want to look at each item? Like this:

    Code (Text):

    Set<Map.Entry<String,JsonElement>> mySet = jsonObject.entrySet();
    System.out.println("mySet as 'key : value'");
    for(Map.Entry<String,JsonElement> singleItem : mySet)
    {
        System.out.println(singleItem.getKey() + " : " + singleItem.getValue());
    }
     
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: JAVA, EntrySet(), iterator
  1. Java Resources (Replies: 4)

  2. [Java] PNGException (Replies: 2)

  3. JAVA GridLayout (Replies: 1)

  4. Java interpreter (Replies: 8)

  5. Java Cylinders (Replies: 2)

Loading...