Created
March 3, 2016 23:45
-
-
Save paxti/6fb4da4b8779f810ab6b to your computer and use it in GitHub Desktop.
Filter JSONArray using attribute of JSONObject
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private ArrayList<JSONObject> getFilteredList(JSONArray options){ | |
Map<String, JSONObject> map = new ArrayMap<>(); | |
for (int i = 0; i < options.length(); i++){ | |
try { | |
JSONObject object = options.getJSONObject(i); | |
String key = object.getString("Order_Type__c") + object.getString("Opp_SFID__c"); | |
if (!map.containsKey(key)){ | |
map.put(key, object); | |
} | |
} catch (JSONException e) { | |
e.printStackTrace(); | |
} | |
} | |
return new ArrayList<JSONObject>(map.values()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment