APIClient: Keep the map order return from the API

The getMapStrValue return a map from the API. This change the
implementation to use linkedHashMap so the map will be sorted according
to the API order.

Signed-off-by: Amnon Heiman <amnon@scylladb.com>
This commit is contained in:
Amnon Heiman 2016-12-28 12:45:33 +02:00
parent 6f916b9d8e
commit b9328960cc

View File

@ -10,6 +10,7 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -406,7 +407,7 @@ public class APIClient {
} }
JsonReader reader = getReader(string, queryParams); JsonReader reader = getReader(string, queryParams);
JsonArray arr = reader.readArray(); JsonArray arr = reader.readArray();
Map<String, String> map = new HashMap<String, String>(); Map<String, String> map = new LinkedHashMap<String, String>();
for (int i = 0; i < arr.size(); i++) { for (int i = 0; i < arr.size(); i++) {
JsonObject obj = arr.getJsonObject(i); JsonObject obj = arr.getJsonObject(i);
if (obj.containsKey("key") && obj.containsKey("value")) { if (obj.containsKey("key") && obj.containsKey("value")) {