@Test public void listToJsonArray_forNull_returnsNull() { assertNull(StripeJsonUtils.listToJsonArray(null)); }
@Nullable @SuppressWarnings("unchecked") static JSONArray listToJsonArray(@Nullable List values) { if (values == null) { return null; } JSONArray jsonArray = new JSONArray(); for (Object object : values) { if (object instanceof Map<?, ?>) { try { Map<String, Object> mapObject = (Map<String, Object>) object; jsonArray.put(mapToJsonObject(mapObject)); } catch (ClassCastException classCastException) { } } else if (object instanceof List<?>) { jsonArray.put(listToJsonArray((List) object)); } else if (object instanceof Number || object instanceof Boolean) { jsonArray.put(object); } else { jsonArray.put(object.toString()); } } return jsonArray; }
StripeJsonUtils { @Nullable @SuppressWarnings("unchecked") static JSONArray listToJsonArray(@Nullable List values) { if (values == null) { return null; } JSONArray jsonArray = new JSONArray(); for (Object object : values) { if (object instanceof Map<?, ?>) { try { Map<String, Object> mapObject = (Map<String, Object>) object; jsonArray.put(mapToJsonObject(mapObject)); } catch (ClassCastException classCastException) { } } else if (object instanceof List<?>) { jsonArray.put(listToJsonArray((List) object)); } else if (object instanceof Number || object instanceof Boolean) { jsonArray.put(object); } else { jsonArray.put(object.toString()); } } return jsonArray; } }
StripeJsonUtils { @Nullable @SuppressWarnings("unchecked") static JSONArray listToJsonArray(@Nullable List values) { if (values == null) { return null; } JSONArray jsonArray = new JSONArray(); for (Object object : values) { if (object instanceof Map<?, ?>) { try { Map<String, Object> mapObject = (Map<String, Object>) object; jsonArray.put(mapToJsonObject(mapObject)); } catch (ClassCastException classCastException) { } } else if (object instanceof List<?>) { jsonArray.put(listToJsonArray((List) object)); } else if (object instanceof Number || object instanceof Boolean) { jsonArray.put(object); } else { jsonArray.put(object.toString()); } } return jsonArray; }  }
StripeJsonUtils { @Nullable @SuppressWarnings("unchecked") static JSONArray listToJsonArray(@Nullable List values) { if (values == null) { return null; } JSONArray jsonArray = new JSONArray(); for (Object object : values) { if (object instanceof Map<?, ?>) { try { Map<String, Object> mapObject = (Map<String, Object>) object; jsonArray.put(mapToJsonObject(mapObject)); } catch (ClassCastException classCastException) { } } else if (object instanceof List<?>) { jsonArray.put(listToJsonArray((List) object)); } else if (object instanceof Number || object instanceof Boolean) { jsonArray.put(object); } else { jsonArray.put(object.toString()); } } return jsonArray; }   }
StripeJsonUtils { @Nullable @SuppressWarnings("unchecked") static JSONArray listToJsonArray(@Nullable List values) { if (values == null) { return null; } JSONArray jsonArray = new JSONArray(); for (Object object : values) { if (object instanceof Map<?, ?>) { try { Map<String, Object> mapObject = (Map<String, Object>) object; jsonArray.put(mapToJsonObject(mapObject)); } catch (ClassCastException classCastException) { } } else if (object instanceof List<?>) { jsonArray.put(listToJsonArray((List) object)); } else if (object instanceof Number || object instanceof Boolean) { jsonArray.put(object); } else { jsonArray.put(object.toString()); } } return jsonArray; }    }