public ListDouble getListDouble(String string) { JsonArray array = getJsonArray(string); return toListDouble(array); }
public List<Object> getColumnValues(String string, List<Class<?>> types) { JsonArray array = getJsonArray(string); List<Object> result = new ArrayList<>(); for (int i = 0; i < types.size(); i++) { Class<?> type = types.get(i); if (String.class.equals(type)) { result.add(toListString(array.getJsonArray(i))); } else if (double.class.equals(type)) { result.add(toListDouble(array.getJsonArray(i))); } else if (float.class.equals(type)) { result.add(toListFloat(array.getJsonArray(i))); } else if (long.class.equals(type)) { result.add(toListLong(array.getJsonArray(i))); } else if (int.class.equals(type)) { result.add(toListInt(array.getJsonArray(i))); } else if (short.class.equals(type)) { result.add(toListShort(array.getJsonArray(i))); } else if (byte.class.equals(type)) { result.add(toListByte(array.getJsonArray(i))); } else if (Instant.class.equals(type)) { result.add(toListTimestamp(array.getJsonArray(i))); } else { throw new IllegalArgumentException("Column type " + type + " not supported"); } } return result; }
/** * Converts the given JSON value to either a vtype, a Java time or a * ListNumber. * * @param msgValue the JSON value * @return the converted type */ public static Object readValueFromJson(JsonValue msgValue) { if (msgValue instanceof JsonObject) { return VTypeToJson.toVType((JsonObject) msgValue); } else if (msgValue instanceof JsonNumber) { return ((JsonNumber) msgValue).doubleValue(); } else if (msgValue instanceof JsonString){ return ((JsonString) msgValue).getString(); } else if (msgValue instanceof JsonArray){ JsonArray array = (JsonArray) msgValue; if (isNumericArray(array)) { return toListDouble(array); } else if (isStringArray(array)) { return toListString(array); } else { return null; } } else { return null; } }