I have a for loop from a JSONarray
and I add the values to a LinkedHashMap
. I would like to avoid adding identical values. I don't know how to do this.
for (int l = 0; l <stops_summaries2.length(); l++){
JSONObject stopObject2 = stops_summaries2.getJSONObject(l);
String stopid2 = stopObject2.getString("id");
System.out.println("stopid2 --->" + stopid2);
String stopurl2 = stopObject2.getString("url");
System.out.println("stopurl2 --->" + stopurl2);
String stopname2 = stopObject2.getString("name");
System.out.println("stopname2 --->" + stopname2);
LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>();
map.put(TAG_NAME, stopname2);
map.put(TAG_SHORT, id);
map.put(TAG_COLOR, stopid2);
itemList.add(map);
}