use of javax.json.JsonReader in project scylla-jmx by scylladb.
the class APIClient method getLongArrValue.
public long[] getLongArrValue(String string, MultivaluedMap<String, String> queryParams) {
JsonReader reader = getReader(string, queryParams);
JsonArray arr = reader.readArray();
long[] res = new long[arr.size()];
for (int i = 0; i < arr.size(); i++) {
res[i] = arr.getJsonNumber(i).longValue();
}
reader.close();
return res;
}
use of javax.json.JsonReader in project scylla-jmx by scylladb.
the class APIClient method getMapListStrValue.
public Map<List<String>, List<String>> getMapListStrValue(String string, MultivaluedMap<String, String> queryParams) {
if (string.equals("")) {
return null;
}
JsonReader reader = getReader(string, queryParams);
JsonArray arr = reader.readArray();
Map<List<String>, List<String>> map = new HashMap<List<String>, List<String>>();
for (int i = 0; i < arr.size(); i++) {
JsonObject obj = arr.getJsonObject(i);
if (obj.containsKey("key") && obj.containsKey("value")) {
map.put(listStrFromJArr(obj.getJsonArray("key")), listStrFromJArr(obj.getJsonArray("value")));
}
}
reader.close();
return map;
}
use of javax.json.JsonReader in project scylla-jmx by scylladb.
the class APIClient method getMapStrValue.
public Map<String, String> getMapStrValue(String string, MultivaluedMap<String, String> queryParams) {
if (string.equals("")) {
return null;
}
JsonReader reader = getReader(string, queryParams);
JsonArray arr = reader.readArray();
Map<String, String> map = new LinkedHashMap<String, String>();
for (int i = 0; i < arr.size(); i++) {
JsonObject obj = arr.getJsonObject(i);
if (obj.containsKey("key") && obj.containsKey("value")) {
map.put(obj.getString("key"), obj.getString("value"));
}
}
reader.close();
return map;
}
use of javax.json.JsonReader in project scylla-jmx by scylladb.
the class APIClient method getListMapStringLongValue.
public Map<String, Long> getListMapStringLongValue(String string, MultivaluedMap<String, String> queryParams) {
if (string.equals("")) {
return null;
}
JsonReader reader = getReader(string, queryParams);
JsonArray arr = reader.readArray();
Map<String, Long> map = new HashMap<String, Long>();
for (int i = 0; i < arr.size(); i++) {
JsonObject obj = arr.getJsonObject(i);
Iterator<String> it = obj.keySet().iterator();
String key = "";
long val = -1;
while (it.hasNext()) {
String k = it.next();
if (obj.get(k) instanceof JsonString) {
key = obj.getString(k);
} else {
val = obj.getJsonNumber(k).longValue();
}
}
if (val > 0 && !key.equals("")) {
map.put(key, val);
}
}
reader.close();
return map;
}
use of javax.json.JsonReader in project scylla-jmx by scylladb.
the class APIClient method getListStrValue.
public List<String> getListStrValue(String string, MultivaluedMap<String, String> queryParams) {
JsonReader reader = getReader(string, queryParams);
JsonArray arr = reader.readArray();
List<String> res = new ArrayList<String>(arr.size());
for (int i = 0; i < arr.size(); i++) {
res.add(arr.getString(i));
}
reader.close();
return res;
}
Aggregations