SchemaUtils { public static List<String> getStringsFromJSONArray(JSONArray jsonStringArray) throws JSONException { List<String> stringArray = Lists.newArrayListWithCapacity(jsonStringArray.length()); for (int stringIndex = 0; stringIndex < jsonStringArray.length(); stringIndex++) { stringArray.add(jsonStringArray.getString(stringIndex)); } return stringArray; } private  SchemaUtils(); static String jarResourceFileToString(String resource); static String inputStreamToString(InputStream inputStream); static boolean checkValidKeys(JSONObject jo, Fields fields); static void checkValidKeysEx(JSONObject jo, Fields fields); static boolean checkValidKeys(JSONObject jo, Collection<Fields> fieldsCollection); static boolean checkValidKeys(JSONObject jo, List<Fields> fieldsCollection); static boolean checkValidKeysEx(JSONObject jo, Collection<Fields> fieldsCollection); static boolean checkValidKeysExHelper(JSONObject jo, Collection<Fields> fieldsCollection); static boolean checkValidKeysEx(JSONObject jo, List<Fields> fieldsCollection); static Set<String> getSetOfJSONKeys(JSONObject jo); static Map<String, String> convertFieldToType(Map<String, Type> fieldToType); static JSONArray findFirstKeyJSONArray(JSONObject jo, String key); static JSONArray findFirstKeyJSONArray(JSONArray ja, String key); static JSONObject findFirstKeyJSONObject(JSONObject jo, String key); static JSONObject findFirstKeyJSONObject(JSONArray ja, String key); static Map<String, String> extractMap(JSONObject jo); static JSONObject createJSONObject(Map<String, String> map); static List<String> getStringsFromJSONArray(JSONArray jsonStringArray); static List<String> getTags(JSONObject jo); static final String FIELD_TAGS; }
@Test public void stringsFromJSONArrayTest() throws Exception { List<String> expected = Lists.newArrayList("a", "b", "c"); JSONArray ja = new JSONArray(); ja.put("a").put("b").put("c"); List<String> result = SchemaUtils.getStringsFromJSONArray(ja); Assert.assertEquals(expected, result); }