Package org.apache.sling.commons.json.util

# Class CDL

java.lang.Object
org.apache.sling.commons.json.util.CDL

@Deprecated public class CDL extends Object
Deprecated.
This provides static methods to convert comma (or otherwise) delimited text into a JSONArray, and to convert a JSONArray into comma (or otherwise) 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 it 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.

Version:
  2016-05-01
Author:
  JSON.org

## Constructor Summary

Constructors
Constructor
Description
`CDL()`
Deprecated.
Constructs a new CDL object.

## Method Summary

Modifier and Type
Method
Description
`static JSONArray`
`rowToJSONArray(JSONTokener x)`
Deprecated.
Produce a JSONArray of strings from a row of comma delimited values.
`static JSONArray`
`rowToJSONArray(JSONTokener x, char delimiter)`
Deprecated.
Produce a JSONArray of strings from a row of comma delimited values.
`static JSONObject`
`rowToJSONObject(JSONArray names, JSONTokener x)`
Deprecated.
Produce a JSONObject from a row of comma delimited text, using a parallel JSONArray of strings to provides the names of the elements.
`static JSONObject`
`rowToJSONObject(JSONArray names, JSONTokener x, char delimiter)`
Deprecated.
Produce a JSONObject from a row of comma delimited text, using a parallel JSONArray of strings to provides the names of the elements.
`static String`
`rowToString(JSONArray ja)`
Deprecated.
Produce a comma delimited text row from a JSONArray.
`static String`
`rowToString(JSONArray ja, char delimiter)`
Deprecated.
Produce a comma delimited text row from a JSONArray.
`static JSONArray`
`toJSONArray(String string)`
Deprecated.
Produce a JSONArray of JSONObjects from a comma delimited text string, using the first row as a source of names.
`static JSONArray`
`toJSONArray(String string, char delimiter)`
Deprecated.
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)`
Deprecated.
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, String string, char delimiter)`
Deprecated.
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)`
Deprecated.
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, char delimiter)`
Deprecated.
Produce a JSONArray of JSONObjects from a comma delimited text string using a supplied JSONArray as the source of element names.
`static JSONArray`
`toJSONArray(JSONTokener x)`
Deprecated.
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, char delimiter)`
Deprecated.
Produce a JSONArray of JSONObjects from a comma delimited text string, using the first row as a source of names.
`static String`
`toString(JSONArray ja)`
Deprecated.
Produce a comma delimited text from a JSONArray of JSONObjects.
`static String`
`toString(JSONArray ja, char delimiter)`
Deprecated.
Produce a comma delimited text from a JSONArray of JSONObjects.
`static String`
`toString(JSONArray names, JSONArray ja)`
Deprecated.
Produce a comma delimited text from a JSONArray of JSONObjects using a provided list of names.
`static String`
`toString(JSONArray names, JSONArray ja, char delimiter)`
Deprecated.
Produce a comma delimited text from a JSONArray of JSONObjects using a provided list of names.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### CDL

public CDL()
Deprecated.
Constructs a new CDL object.

## Method Details

### rowToJSONArray

public static JSONArray rowToJSONArray(JSONTokener x) throws JSONException
Deprecated.
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.
Throws:
  `JSONException` - if a called function fails

### rowToJSONArray

public static JSONArray rowToJSONArray(JSONTokener x, char delimiter) throws JSONException
Deprecated.
Produce a JSONArray of strings from a row of comma delimited values.

Parameters:
  `x` - A JSONTokener of the source text.
  `delimiter` - custom delimiter char
Returns:
  A JSONArray of strings.
Throws:
  `JSONException` - if a called function fails

### rowToJSONObject

public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x) throws JSONException
Deprecated.
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.
Throws:
  `JSONException` - if a called function fails

### rowToJSONObject

public static JSONObject rowToJSONObject(JSONArray names, JSONTokener x, char delimiter) throws JSONException
Deprecated.
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.
  `delimiter` - custom delimiter char
Returns:
  A JSONObject combining the names and values.
Throws:
  `JSONException` - if a called function fails

### rowToString

public static String rowToString(JSONArray ja)
Deprecated.
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.

### rowToString

public static String rowToString(JSONArray ja, char delimiter)
Deprecated.
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.
  `delimiter` - custom delimiter char
Returns:
  A string ending in NEWLINE.

### toJSONArray

public static JSONArray toJSONArray(String string) throws JSONException
Deprecated.
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.
Throws:
  `JSONException` - if a called function fails

### toJSONArray

public static JSONArray toJSONArray(String string, char delimiter) throws JSONException
Deprecated.
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.
  `delimiter` - custom delimiter char
Returns:
  A JSONArray of JSONObjects.
Throws:
  `JSONException` - if a called function fails

### toJSONArray

public static JSONArray toJSONArray(JSONTokener x) throws JSONException
Deprecated.
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.
Throws:
  `JSONException` - if a called function fails

### toJSONArray

public static JSONArray toJSONArray(JSONTokener x, char delimiter) throws JSONException
Deprecated.
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.
  `delimiter` - custom delimiter char
Returns:
  A JSONArray of JSONObjects.
Throws:
  `JSONException` - if a called function fails

### toJSONArray

public static JSONArray toJSONArray(JSONArray names, String string) throws JSONException
Deprecated.
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.
Throws:
  `JSONException` - if a called function fails

### toJSONArray

public static JSONArray toJSONArray(JSONArray names, String string, char delimiter) throws JSONException
Deprecated.
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.
  `delimiter` - custom delimiter char
Returns:
  A JSONArray of JSONObjects.
Throws:
  `JSONException` - if a called function fails

### toJSONArray

public static JSONArray toJSONArray(JSONArray names, JSONTokener x) throws JSONException
Deprecated.
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.
Throws:
  `JSONException` - if a called function fails

### toJSONArray

public static JSONArray toJSONArray(JSONArray names, JSONTokener x, char delimiter) throws JSONException
Deprecated.
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.
  `delimiter` - custom delimiter char
Returns:
  A JSONArray of JSONObjects.
Throws:
  `JSONException` - if a called function fails

### toString

public static String toString(JSONArray ja) throws JSONException
Deprecated.
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.
Throws:
  `JSONException` - if a called function fails

### toString

public static String toString(JSONArray ja, char delimiter) throws JSONException
Deprecated.
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.
  `delimiter` - custom delimiter char
Returns:
  A comma delimited text.
Throws:
  `JSONException` - if a called function fails

### toString

public static String toString(JSONArray names, JSONArray ja) throws JSONException
Deprecated.
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.
Throws:
  `JSONException` - if a called function fails

### toString

public static String toString(JSONArray names, JSONArray ja, char delimiter) throws JSONException
Deprecated.
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.
  `delimiter` - custom delimiter char
Returns:
  A comma delimited text.
Throws:
  `JSONException` - if a called function fails