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 correspondingKeyedValues
instance.static KeyedValues
<String, Number> readKeyedValues
(String json) Parses the supplied JSON string into aKeyedValues
instance.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 aKeyedValues3D
instance.static KeyedValues3D
<String, String, String, Number> readKeyedValues3D
(String json) Parses the supplied string and (if possible) creates aKeyedValues3D
instance.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 String
writeKeyedValues
(KeyedValues data) Returns a string containing the data in JSON format.static void
writeKeyedValues
(KeyedValues data, Writer writer) Writes the data in JSON format to the supplied writer.static String
Writes a data table to a string in JSON format.static void
writeKeyedValues2D
(KeyedValues2D data, Writer writer) Writes the data in JSON format to the supplied writer.static String
writeKeyedValues3D
(KeyedValues3D dataset) Returns a string containing the data in JSON format.static void
writeKeyedValues3D
(KeyedValues3D dataset, Writer writer) Writes the dataset in JSON format to the supplied writer.static String
writeXYZDataset
(XYZDataset dataset) Returns a string containing the dataset in JSON format.static void
writeXYZDataset
(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 aKeyedValues
instance.
Implementation note: this method returns an instance ofStandardPieDataset3D
).- Parameters:
json
- the JSON string (null
not permitted).- Returns:
- A
KeyedValues
instance.
-
readKeyedValues
Parses characters from the supplied reader and returns the correspondingKeyedValues
instance.
Implementation note: this method returns an instance ofStandardPieDataset3D
).- Parameters:
reader
- the reader (null
not permitted).- Returns:
- A
KeyedValues
instance. - 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 (null
not 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 (null
not permitted).writer
- the writer (null
not permitted).- Throws:
IOException
- if there is an I/O problem.
-
readKeyedValues2D
Reads a data table from a JSON format string.- Parameters:
json
- the string (null
not 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 (null
not 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 (null
not permitted).- Returns:
- The string.
-
writeKeyedValues2D
Writes the data in JSON format to the supplied writer.- Parameters:
data
- the data (null
not permitted).writer
- the writer (null
not permitted).- Throws:
IOException
- if there is an I/O problem.
-
readKeyedValues3D
Parses the supplied string and (if possible) creates aKeyedValues3D
instance.- Parameters:
json
- the JSON string (null
not permitted).- Returns:
- A
KeyedValues3D
instance.
-
readKeyedValues3D
public static KeyedValues3D<String,String, readKeyedValues3DString, Number> (Reader reader) throws IOException Parses character data from the reader and (if possible) creates aKeyedValues3D
instance. This method will read back the data written bywriteKeyedValues3D(org.jfree.chart3d.data.KeyedValues3D, java.io.Writer)
.- Parameters:
reader
- the reader (null
not permitted).- Returns:
- A
KeyedValues3D
instance. - Throws:
IOException
- if there is an I/O problem.
-
writeKeyedValues3D
Returns a string containing the data in JSON format.- Parameters:
dataset
- the data (null
not permitted).- Returns:
- A string in JSON format.
-
writeKeyedValues3D
Writes the dataset in JSON format to the supplied writer.- Parameters:
dataset
- the dataset (null
not permitted).writer
- the writer (null
not 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 (null
not 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 (null
not 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 (null
not permitted).- Returns:
- A string in JSON format.
-
writeXYZDataset
Writes the dataset in JSON format to the supplied writer.- Parameters:
dataset
- the data (null
not permitted).writer
- the writer (null
not permitted).- Throws:
IOException
- if there is an I/O problem.
-