org.json.CDL Class Reference

List of all members.

Static Public Member Functions

static JSONArray rowToJSONArray (JSONTokener x) throws JSONException
static JSONObject rowToJSONObject (JSONArray names, JSONTokener x) throws JSONException
static JSONArray toJSONArray (String string) throws JSONException
static JSONArray toJSONArray (JSONTokener x) throws JSONException
static JSONArray toJSONArray (JSONArray names, String string) throws JSONException
static JSONArray toJSONArray (JSONArray names, JSONTokener x) throws JSONException
static String rowToString (JSONArray ja)
static String toString (JSONArray ja) throws JSONException
static String toString (JSONArray names, JSONArray ja) throws JSONException

Detailed Description

This provides static methods to convert comma delimited text into a JSONArray, and to covert a JSONArray into comma delimited text. Comma delimited text is a very popular format for data interchange. It is understood by most database, spreadsheet, and organizer programs.

Each row of text represents a row in a table or a data record. Each row ends with a NEWLINE character. Each row contains one or more values. Values are separated by commas. A value can contain any character except for comma, unless is is wrapped in single quotes or double quotes.

The first row usually contains the names of the columns.

A comma delimited list can be converted into a JSONArray of JSONObjects. The names for the elements in the JSONObjects can be taken from the names in the first row.

Author:
JSON.org
Version:
2009-09-11

Member Function Documentation

static JSONArray org.json.CDL.rowToJSONArray ( JSONTokener  x  )  throws JSONException [static]

Produce a JSONArray of strings from a row of comma delimited values.

Parameters:
x A JSONTokener of the source text.
Returns:
A JSONArray of strings.
Exceptions:
JSONException 
static JSONObject org.json.CDL.rowToJSONObject ( JSONArray  names,
JSONTokener  x 
) throws JSONException [static]

Produce a JSONObject from a row of comma delimited text, using a parallel JSONArray of strings to provides the names of the elements.

Parameters:
names A JSONArray of names. This is commonly obtained from the first row of a comma delimited text file using the rowToJSONArray method.
x A JSONTokener of the source text.
Returns:
A JSONObject combining the names and values.
Exceptions:
JSONException 
static String org.json.CDL.rowToString ( JSONArray  ja  )  [static]

Produce a comma delimited text row from a JSONArray. Values containing the comma character will be quoted. Troublesome characters may be removed.

Parameters:
ja A JSONArray of strings.
Returns:
A string ending in NEWLINE.
static JSONArray org.json.CDL.toJSONArray ( JSONArray  names,
JSONTokener  x 
) throws JSONException [static]

Produce a JSONArray of JSONObjects from a comma delimited text string using a supplied JSONArray as the source of element names.

Parameters:
names A JSONArray of strings.
x A JSONTokener of the source text.
Returns:
A JSONArray of JSONObjects.
Exceptions:
JSONException 
static JSONArray org.json.CDL.toJSONArray ( JSONArray  names,
String  string 
) throws JSONException [static]

Produce a JSONArray of JSONObjects from a comma delimited text string using a supplied JSONArray as the source of element names.

Parameters:
names A JSONArray of strings.
string The comma delimited text.
Returns:
A JSONArray of JSONObjects.
Exceptions:
JSONException 
static JSONArray org.json.CDL.toJSONArray ( JSONTokener  x  )  throws JSONException [static]

Produce a JSONArray of JSONObjects from a comma delimited text string, using the first row as a source of names.

Parameters:
x The JSONTokener containing the comma delimited text.
Returns:
A JSONArray of JSONObjects.
Exceptions:
JSONException 
static JSONArray org.json.CDL.toJSONArray ( String  string  )  throws JSONException [static]

Produce a JSONArray of JSONObjects from a comma delimited text string, using the first row as a source of names.

Parameters:
string The comma delimited text.
Returns:
A JSONArray of JSONObjects.
Exceptions:
JSONException 
static String org.json.CDL.toString ( JSONArray  names,
JSONArray  ja 
) throws JSONException [static]

Produce a comma delimited text from a JSONArray of JSONObjects using a provided list of names. The list of names is not included in the output.

Parameters:
names A JSONArray of strings.
ja A JSONArray of JSONObjects.
Returns:
A comma delimited text.
Exceptions:
JSONException 
static String org.json.CDL.toString ( JSONArray  ja  )  throws JSONException [static]

Produce a comma delimited text from a JSONArray of JSONObjects. The first row will be a list of names obtained by inspecting the first JSONObject.

Parameters:
ja A JSONArray of JSONObjects.
Returns:
A comma delimited text.
Exceptions:
JSONException