Package adams.data.report
Class ReportJsonUtils
- java.lang.Object
-
- adams.data.report.ReportJsonUtils
-
public class ReportJsonUtils extends Object
For converting reports to JSON and vice versa.- Author:
- FracPete (fracpete at waikato dot ac dot nz)
-
-
Constructor Summary
Constructors Constructor Description ReportJsonUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Stringexample()Returns an example report in JSON.static ReportfromJson(com.google.gson.JsonObject jobj)Creates a report from the JSON object.static ReportfromJson(com.google.gson.JsonObject jobj, String prefix)Creates a report from the JSON object.static ReportfromJson(Reader reader)Creates a report from the reader, reading in JSON.static ReportfromJson(Reader reader, String prefix)Creates a report from the reader, reading in JSON.static com.google.gson.JsonObjecttoJson(Report report)Turns the report into a json structure.static com.google.gson.JsonObjecttoJson(Report report, Field[] fields)Turns the specified fields from the report into a json structure.
-
-
-
Method Detail
-
example
public static String example()
Returns an example report in JSON.- Returns:
- the example string
-
fromJson
public static Report fromJson(Reader reader) throws Exception
Creates a report from the reader, reading in JSON.- Parameters:
reader- the reader to obtain the JSON from- Returns:
- the report, null if failed to create or find data
- Throws:
Exception- if reading/parsing fails
-
fromJson
public static Report fromJson(Reader reader, String prefix) throws Exception
Creates a report from the reader, reading in JSON.- Parameters:
reader- the reader to obtain the JSON fromprefix- the prefix to use for the fields, ignored if null- Returns:
- the report, null if failed to create or find data
- Throws:
Exception- if reading/parsing fails
-
fromJson
public static Report fromJson(com.google.gson.JsonObject jobj)
Creates a report from the JSON object.- Parameters:
jobj- the object to get the data from- Returns:
- the report, null if failed to create or find data
-
fromJson
public static Report fromJson(com.google.gson.JsonObject jobj, String prefix)
Creates a report from the JSON object.- Parameters:
jobj- the object to get the data fromprefix- the prefix to use for the fields, ignored if null- Returns:
- the report, null if failed to create or find data
-
toJson
public static com.google.gson.JsonObject toJson(Report report)
Turns the report into a json structure.- Parameters:
report- the report to convert- Returns:
- the json data structure
-
-