Node Director
Static Public Member Functions | List of all members
org.json.CDL Class Reference

This provides static methods to convert comma delimited text into a JSONArray, and to covert a JSONArray into comma delimited text. More...

Static Public Member Functions

static JSONArray rowToJSONArray (JSONTokener x) throws ParseException
 Produce a JSONArray of strings from a row of comma delimited values.
static JSONObject rowToJSONObject (JSONArray names, JSONTokener x) throws ParseException
 Produce a JSONObject from a row of comma delimited text, using a parallel JSONArray of strings to provides the names of the elements.
static JSONArray toJSONArray (String string) throws ParseException
 Produce a JSONArray of JSONObjects from a comma delimited text string, using the first row as a source of names.
static JSONArray toJSONArray (JSONTokener x) throws ParseException
 Produce a JSONArray of JSONObjects from a comma delimited text string, using the first row as a source of names.
static JSONArray toJSONArray (JSONArray names, String string) throws ParseException
 Produce a JSONArray of JSONObjects from a comma delimited text string using a supplied JSONArray as the source of element names.
static JSONArray toJSONArray (JSONArray names, JSONTokener x) throws java.text.ParseException
 Produce a JSONArray of JSONObjects from a comma delimited text string using a supplied JSONArray as the source of element names.
static String rowToString (JSONArray ja)
 Produce a comma delimited text row from a JSONArray.
static String toString (JSONArray ja)
 Produce a comma delimited text from a JSONArray of JSONObjects.
static String toString (JSONArray names, JSONArray ja)
 Produce a comma delimited text from a JSONArray of JSONObjects using a provided list of names.

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.

Member Function Documentation

static JSONArray org.json.CDL.rowToJSONArray ( JSONTokener  x) throws ParseException
static

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

Parameters
xA JSONTokener of the source text.
Returns
A JSONArray of strings.
Exceptions
ParseException

References org.json.JSONTokener.next(), org.json.JSONArray.put(), and org.json.JSONTokener.syntaxError().

Referenced by org.json.CDL.rowToJSONObject(), and org.json.CDL.toJSONArray().

static JSONObject org.json.CDL.rowToJSONObject ( JSONArray  names,
JSONTokener  x 
) throws ParseException
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
namesA JSONArray of names. This is commonly obtained from the first row of a comma delimited text file using the rowToJSONArray method.
xA JSONTokener of the source text.
Returns
A JSONObject combining the names and values.
Exceptions
ParseException

References org.json.CDL.rowToJSONArray(), and org.json.JSONArray.toJSONObject().

Referenced by org.json.CDL.toJSONArray().

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.

Parameters
jaA JSONArray of strings.
Returns
A string ending in NEWLINE.

References org.json.JSONArray.length(), and org.json.JSONArray.opt().

Referenced by org.json.CDL.toString().

static JSONArray org.json.CDL.toJSONArray ( String  string) throws ParseException
static

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

Parameters
stringThe comma delimited text.
Returns
A JSONArray of JSONObjects.
Exceptions
ParseException

Referenced by org.json.Test.main(), and org.json.CDL.toJSONArray().

static JSONArray org.json.CDL.toJSONArray ( JSONTokener  x) throws ParseException
static

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

Parameters
xThe JSONTokener containing the comma delimited text.
Returns
A JSONArray of JSONObjects.
Exceptions
ParseException

References org.json.CDL.rowToJSONArray(), and org.json.CDL.toJSONArray().

static JSONArray org.json.CDL.toJSONArray ( JSONArray  names,
String  string 
) throws ParseException
static

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

Parameters
namesA JSONArray of strings.
stringThe comma delimited text.
Returns
A JSONArray of JSONObjects.
Exceptions
ParseException

References org.json.CDL.toJSONArray().

static JSONArray org.json.CDL.toJSONArray ( JSONArray  names,
JSONTokener  x 
) throws java.text.ParseException
static

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

Parameters
namesA JSONArray of strings.
xA JSONTokener of the source text.
Returns
A JSONArray of JSONObjects.
Exceptions
java.text.ParseException

References org.json.JSONArray.length(), org.json.JSONArray.put(), and org.json.CDL.rowToJSONObject().

static String org.json.CDL.toString ( JSONArray  ja)
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
jaA JSONArray of JSONObjects.
Returns
A comma delimited text.

References org.json.JSONObject.names(), org.json.JSONArray.optJSONObject(), and org.json.CDL.rowToString().

Referenced by org.json.Test.main().

static String org.json.CDL.toString ( JSONArray  names,
JSONArray  ja 
)
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
namesA JSONArray of strings.
jaA JSONArray of JSONObjects.
Returns
A comma delimited text.

References org.json.JSONArray.length(), org.json.JSONArray.optJSONObject(), org.json.CDL.rowToString(), org.json.JSONObject.toJSONArray(), and org.json.JSONObject.toString().


The documentation for this class was generated from the following file: