java.lang.Object
org.jfree.chart3d.data.JSONUtils
Utility methods for interchange between datasets (
KeyedValues,
KeyedValues3D and XYZDataset) and JSON format strings.- Since:
- 1.3
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic KeyedValues<String, Number> readKeyedValues(Reader reader) Parses characters from the supplied reader and returns the correspondingKeyedValuesinstance.static KeyedValues<String, Number> readKeyedValues(String json) Parses the supplied JSON string into aKeyedValuesinstance.static KeyedValues2D<String, String, Number> readKeyedValues2D(Reader reader) Reads a data table from a JSON format string coming from the specified reader.static KeyedValues2D<String, String, Number> readKeyedValues2D(String json) Reads a data table from a JSON format string.static KeyedValues3D<String, String, String, Number> readKeyedValues3D(Reader reader) Parses character data from the reader and (if possible) creates aKeyedValues3Dinstance.static KeyedValues3D<String, String, String, Number> readKeyedValues3D(String json) Parses the supplied string and (if possible) creates aKeyedValues3Dinstance.static XYZDataset<String> readXYZDataset(Reader reader) Parses character data from the reader and (if possible) creates an {XYZDataset} instance that represents the data.static XYZDataset<String> readXYZDataset(String json) Parses the string and (if possible) creates an {XYZDataset} instance that represents the data.static StringwriteKeyedValues(KeyedValues data) Returns a string containing the data in JSON format.static voidwriteKeyedValues(KeyedValues data, Writer writer) Writes the data in JSON format to the supplied writer.static StringWrites a data table to a string in JSON format.static voidwriteKeyedValues2D(KeyedValues2D data, Writer writer) Writes the data in JSON format to the supplied writer.static StringwriteKeyedValues3D(KeyedValues3D dataset) Returns a string containing the data in JSON format.static voidwriteKeyedValues3D(KeyedValues3D dataset, Writer writer) Writes the dataset in JSON format to the supplied writer.static StringwriteXYZDataset(XYZDataset dataset) Returns a string containing the dataset in JSON format.static voidwriteXYZDataset(XYZDataset dataset, Writer writer) Writes the dataset in JSON format to the supplied writer.
-
Constructor Details
-
JSONUtils
public JSONUtils()
-
-
Method Details
-
readKeyedValues
Parses the supplied JSON string into aKeyedValuesinstance.
Implementation note: this method returns an instance ofStandardPieDataset3D).- Parameters:
json- the JSON string (nullnot permitted).- Returns:
- A
KeyedValuesinstance.
-
readKeyedValues
Parses characters from the supplied reader and returns the correspondingKeyedValuesinstance.
Implementation note: this method returns an instance ofStandardPieDataset3D).- Parameters:
reader- the reader (nullnot permitted).- Returns:
- A
KeyedValuesinstance. - Throws:
IOException- if there is an I/O problem.
-
writeKeyedValues
Returns a string containing the data in JSON format. The format is an array of arrays, where each sub-array represents one data value. The sub-array should contain two items, first the item key as a string and second the item value as a number. For example:[["Key A", 1.0], ["Key B", 2.0]]
Note that this method can be used with instances ofPieDataset3D.- Parameters:
data- the data (nullnot permitted).- Returns:
- A string in JSON format.
-
writeKeyedValues
Writes the data in JSON format to the supplied writer.
Note that this method can be used with instances ofPieDataset3D.- Parameters:
data- the data (nullnot permitted).writer- the writer (nullnot permitted).- Throws:
IOException- if there is an I/O problem.
-
readKeyedValues2D
Reads a data table from a JSON format string.- Parameters:
json- the string (nullnot permitted).- Returns:
- A data table.
-
readKeyedValues2D
public static KeyedValues2D<String,String, readKeyedValues2DNumber> (Reader reader) throws IOException Reads a data table from a JSON format string coming from the specified reader.- Parameters:
reader- the reader (nullnot permitted).- Returns:
- A data table.
- Throws:
IOException- if there is an I/O problem.
-
writeKeyedValues2D
Writes a data table to a string in JSON format.- Parameters:
data- the data (nullnot permitted).- Returns:
- The string.
-
writeKeyedValues2D
Writes the data in JSON format to the supplied writer.- Parameters:
data- the data (nullnot permitted).writer- the writer (nullnot permitted).- Throws:
IOException- if there is an I/O problem.
-
readKeyedValues3D
Parses the supplied string and (if possible) creates aKeyedValues3Dinstance.- Parameters:
json- the JSON string (nullnot permitted).- Returns:
- A
KeyedValues3Dinstance.
-
readKeyedValues3D
public static KeyedValues3D<String,String, readKeyedValues3DString, Number> (Reader reader) throws IOException Parses character data from the reader and (if possible) creates aKeyedValues3Dinstance. This method will read back the data written bywriteKeyedValues3D(org.jfree.chart3d.data.KeyedValues3D, java.io.Writer).- Parameters:
reader- the reader (nullnot permitted).- Returns:
- A
KeyedValues3Dinstance. - Throws:
IOException- if there is an I/O problem.
-
writeKeyedValues3D
Returns a string containing the data in JSON format.- Parameters:
dataset- the data (nullnot permitted).- Returns:
- A string in JSON format.
-
writeKeyedValues3D
Writes the dataset in JSON format to the supplied writer.- Parameters:
dataset- the dataset (nullnot permitted).writer- the writer (nullnot permitted).- Throws:
IOException- if there is an I/O problem.
-
readXYZDataset
Parses the string and (if possible) creates an {XYZDataset} instance that represents the data. This method will read back the data that is written bywriteXYZDataset(org.jfree.chart3d.data.xyz.XYZDataset).- Parameters:
json- a JSON formatted string (nullnot permitted).- Returns:
- A dataset.
- See Also:
-
readXYZDataset
Parses character data from the reader and (if possible) creates an {XYZDataset} instance that represents the data.- Parameters:
reader- a reader (nullnot permitted).- Returns:
- A dataset.
- Throws:
IOException- if there is an I/O problem.
-
writeXYZDataset
Returns a string containing the dataset in JSON format.- Parameters:
dataset- the dataset (nullnot permitted).- Returns:
- A string in JSON format.
-
writeXYZDataset
Writes the dataset in JSON format to the supplied writer.- Parameters:
dataset- the data (nullnot permitted).writer- the writer (nullnot permitted).- Throws:
IOException- if there is an I/O problem.
-