/** * Produce a JSONArray of strings from a row of comma delimited values.<p> * * @param x A JSONTokener of the source text * @return A JSONArray of strings * @throws JSONException if something goes wrong */ public static JSONArray rowToJSONArray(JSONTokener x) throws JSONException { JSONArray ja = new JSONArray(); for (;;) { String value = getValue(x); if ((value == null) || ((ja.length() == 0) && (value.length() == 0))) { return null; } ja.put(value); for (;;) { char c = x.next(); if (c == ',') { break; } if (c != ' ') { if ((c == '\n') || (c == '\r') || (c == 0)) { return ja; } throw x.syntaxError("Bad character '" + c + "' (" + (int)c + ")."); } } } }
/** * Produce a JSONArray of strings from a row of comma delimited values.<p> * * @param x A JSONTokener of the source text * @return A JSONArray of strings * @throws JSONException if something goes wrong */ public static JSONArray rowToJSONArray(JSONTokener x) throws JSONException { JSONArray ja = new JSONArray(); for (;;) { String value = getValue(x); if (value == null || (ja.length() == 0 && value.length() == 0)) { return null; } ja.put(value); for (;;) { char c = x.next(); if (c == ',') { break; } if (c != ' ') { if (c == '\n' || c == '\r' || c == 0) { return ja; } throw x.syntaxError("Bad character '" + c + "' (" + (int)c + ")."); } } } }