/** * Produce a JSONArray of JSONObjects from a comma delimited text string, * using the first row as a source of names.<p> * * @param x The JSONTokener containing the comma delimited text * @return A JSONArray of JSONObjects * @throws JSONException if something goes wrong */ public static JSONArray toJSONArray(JSONTokener x) throws JSONException { return toJSONArray(rowToJSONArray(x), x); }
/** * Produce a JSONArray of JSONObjects from a comma delimited text string, * using the first row as a source of names.<p> * * @param x The JSONTokener containing the comma delimited text * @return A JSONArray of JSONObjects * @throws JSONException if something goes wrong */ public static JSONArray toJSONArray(JSONTokener x) throws JSONException { return toJSONArray(rowToJSONArray(x), x); }
/** * Produce a JSONObject from a row of comma delimited text, using a * parallel JSONArray of strings to provides the names of the elements.<p> * * @param names A JSONArray of names. This is commonly obtained from the * first row of a comma delimited text file using the rowToJSONArray * method * @param x A JSONTokener of the source text * @return A JSONObject combining the names and values * @throws JSONException if something goes wrong */ public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x) throws JSONException { JSONArray ja = rowToJSONArray(x); return ja != null ? ja.toJSONObject(names) : null; }
/** * Produce a JSONObject from a row of comma delimited text, using a * parallel JSONArray of strings to provides the names of the elements.<p> * * @param names A JSONArray of names. This is commonly obtained from the * first row of a comma delimited text file using the rowToJSONArray * method * @param x A JSONTokener of the source text * @return A JSONObject combining the names and values * @throws JSONException if something goes wrong */ public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x) throws JSONException { JSONArray ja = rowToJSONArray(x); return ja != null ? ja.toJSONObject(names) : null; }