-5

Suppose we've a HashMap as follows:

{tones=
  [
    {score=0.534486, tone_id=joy, tone_name=Joy},
    {score=0.619262, tone_id=sadness, tone_name=Sadness},
    {score=0.829266, tone_id=analytical, tone_name=Analytical}
  ]
}

and we've to extract only "score" values and "tone_name" values from this, how can we do this?

nvioli
  • 4,137
  • 3
  • 22
  • 38

1 Answers1

1

Try this:

Iterator it = tones.entrySet().iterator();
    while (it.hasNext()) {
        Map.Entry pair = (Map.Entry)it.next();
        if("score".equalsIgnoreCase(pair.getValue()) || "tone_name".equalsIgnoreCase(pair.getValue())){
            iter.remove();
        }
    }
kaan bobac
  • 729
  • 4
  • 8