/** * Produce a JSONArray of JSONObjects from a comma delimited text string * using a supplied JSONArray as the source of element names.<p> * * @param names A JSONArray of strings * @param x A JSONTokener of the source text * @return A JSONArray of JSONObjects * @throws JSONException if something goes wrong */ public static JSONArray toJSONArray(JSONArray names, JSONTokener x) throws JSONException { if ((names == null) || (names.length() == 0)) { return null; } JSONArray ja = new JSONArray(); for (;;) { JSONObject jo = rowToJSONObject(names, x); if (jo == null) { break; } ja.put(jo); } if (ja.length() == 0) { return null; } return ja; }
/** * Produce a JSONArray of JSONObjects from a comma delimited text string * using a supplied JSONArray as the source of element names.<p> * * @param names A JSONArray of strings * @param x A JSONTokener of the source text * @return A JSONArray of JSONObjects * @throws JSONException if something goes wrong */ public static JSONArray toJSONArray(JSONArray names, JSONTokener x) throws JSONException { if (names == null || names.length() == 0) { return null; } JSONArray ja = new JSONArray(); for (;;) { JSONObject jo = rowToJSONObject(names, x); if (jo == null) { break; } ja.put(jo); } if (ja.length() == 0) { return null; } return ja; }