public static JSONArray rowToJSONArray(JSONTokener x) throws JSONException {
        JSONArray ja = new JSONArray();
        for (; ;) {
            String value = getValue(x);
            if (value == null) {
                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 + ").");
                }
            }
        }
    }