public class JsonMethods extends Object
Constructor and Description |
---|
JsonMethods() |
Modifier and Type | Method and Description |
---|---|
static io.toro.gloop.object.cursor.GloopCursor |
getInputCursorFromFile(String filename,
String encoding,
List<String> jsonNodeNames,
io.toro.gloop.engine.GloopExecutionContext context)
Parses a large JSON file.
|
static io.toro.gloop.object.cursor.GloopCursor |
getInputCursorFromInputStream(InputStream inputStream,
String encoding,
List<String> jsonNodeNames,
io.toro.gloop.engine.GloopExecutionContext context)
Parses a large JSON input stream.
|
static String |
gloopObjectToJsonString(io.toro.gloop.object.property.GloopObject gloopObject)
Convert a gloop object to JSON
|
static String |
gloopObjectToJsonString(io.toro.gloop.object.property.GloopObject gloopObject,
boolean includeRoot,
boolean includeNulls)
Convert a gloop object to a json string
|
static io.toro.gloop.object.property.GloopObject |
inputStreamToGloopObject(InputStream jsonInputStream)
Convert an input stream containing json data to a gloop object
|
static io.toro.gloop.object.property.GloopObject |
jsonStringToGloopObject(String jsonString)
Convert a JSON String to a gloop object
|
static io.toro.gloop.object.property.GloopModel |
openJsonOutputCursor(boolean prettyPrint,
boolean printStartDocumentBrace,
boolean printCommaAtStart,
boolean printStartArrayBracket,
boolean printEndArrayBracket,
boolean printEndDocumentBrace,
String name,
String indent,
boolean closeDestination,
Object destination,
io.toro.gloop.engine.GloopExecutionContext context)
Opens a cursor used to write large amounts of json data
|
static void |
printJson(IndentPrinter printer,
io.toro.gloop.object.property.GloopObject gloopObject,
boolean includeNulls,
boolean includeRoot,
boolean pretty)
Marshalls the given gloop object to an indent printer
|
static io.toro.gloop.object.property.GloopObject |
readerToGloopObject(Reader jsonReader)
Convert a reader containing json data to a gloop object
|
static void |
writeJson(Writer writer,
io.toro.gloop.object.property.GloopObject gloopObject,
boolean includeNulls,
boolean includeRoot,
boolean pretty)
Marshalls the given gloop object to a writer
|
@GloopParameter(name="gloopJson") public static String gloopObjectToJsonString(io.toro.gloop.object.property.GloopObject gloopObject)
gloopObject
- The gloop object to marshall as JSONpublic static String gloopObjectToJsonString(@GloopParameter(allowNull=false) io.toro.gloop.object.property.GloopObject gloopObject, @GloopParameter(defaultValue="false") boolean includeRoot, @GloopParameter(defaultValue="false") boolean includeNulls)
gloopObject
- The gloop object to convert to a JSON StringincludeRoot
- If the glopo Object is a model, this flag will state whether to include the name of the gloop
model in the root of the json objectincludeNulls
- If true, null properties will be marshalledpublic static io.toro.gloop.object.property.GloopObject jsonStringToGloopObject(String jsonString)
jsonString
- The JSON string to unmarshall to a gloop objectpublic static io.toro.gloop.object.property.GloopObject inputStreamToGloopObject(InputStream jsonInputStream)
jsonInputStream
- The input stream containing the JSON datapublic static io.toro.gloop.object.property.GloopObject readerToGloopObject(Reader jsonReader)
jsonReader
- The reader containing the gloop objectpublic static void writeJson(@GloopParameter(allowNull=false) Writer writer, @GloopParameter(allowNull=false) io.toro.gloop.object.property.GloopObject gloopObject, @GloopParameter(defaultValue="false") boolean includeNulls, @GloopParameter(defaultValue="false") boolean includeRoot, @GloopParameter(defaultValue="true") boolean pretty)
writer
- The writer to write the data togloopObject
- The gloop objectincludeNulls
- If true, null properties will be marshalledincludeRoot
- If the glopo Object is a model, this flag will state whether to include the name of the gloop
model in the root of the json objectpretty
- Whether to write the JSON using indentation and new lines to make it easier to readpublic static void printJson(@GloopParameter(allowNull=false) IndentPrinter printer, @GloopParameter(allowNull=false) io.toro.gloop.object.property.GloopObject gloopObject, @GloopParameter(defaultValue="false") boolean includeNulls, @GloopParameter(defaultValue="false") boolean includeRoot, @GloopParameter(defaultValue="true") boolean pretty)
printer
- The printer to write the data togloopObject
- The gloop objectincludeNulls
- If true, null properties will be marshalledincludeRoot
- If the glopo Object is a model, this flag will state whether to include the name of the gloop
model in the root of the json objectpretty
- Whether to write the JSON using indentation and new lines to make it easier to read@GloopObjectParameter(value="gloopJsonCursor{\n gloopJsonCursor[]{\n nodeName\n cursorRecord:object\n }\n}") public static io.toro.gloop.object.cursor.GloopCursor getInputCursorFromFile(String filename, @GloopParameter(defaultValue="UTF-8") String encoding, List<String> jsonNodeNames, io.toro.gloop.engine.GloopExecutionContext context) throws IOException
filename
- The name of the file containing the JSON dataencoding
- The encoding of the JSON data. Default value is UTF-8jsonNodeNames
- The names of the JSON objects to seek to whilst parsing the datacontext
- The Gloop Execution Context, Gloop maps this automaticallyIOException
@GloopObjectParameter(value="gloopJsonCursor{\n gloopJsonCursor[]{\n nodeName\n cursorRecord:object\n }\n}") public static io.toro.gloop.object.cursor.GloopCursor getInputCursorFromInputStream(InputStream inputStream, @GloopParameter(defaultValue="UTF-8") String encoding, List<String> jsonNodeNames, io.toro.gloop.engine.GloopExecutionContext context) throws IOException
inputStream
- The inputstream containing the JSON dataencoding
- The encoding of the JSON data. Default value is UTF-8jsonNodeNames
- The names of the JSON objects to seek to whilst parsing the datacontext
- The Gloop Execution Context, Gloop maps this automaticallyIOException
@GloopObjectParameter(value="output{\n jsonCursorOutput{\n indentPrinter:object:printer used to write the json out to::::groovy.util.IndentPrinter\n jsonOutputCursor[]*{\n }\n }\n}") public static io.toro.gloop.object.property.GloopModel openJsonOutputCursor(@GloopParameter(defaultValue="true") boolean prettyPrint, @GloopParameter(defaultValue="true") boolean printStartDocumentBrace, @GloopParameter(defaultValue="true") boolean printCommaAtStart, @GloopParameter(defaultValue="true") boolean printStartArrayBracket, @GloopParameter(defaultValue="true") boolean printEndArrayBracket, @GloopParameter(defaultValue="true") boolean printEndDocumentBrace, String name, @GloopParameter(allowNull=false,defaultValue=" ") String indent, @GloopParameter(defaultValue="true") boolean closeDestination, Object destination, io.toro.gloop.engine.GloopExecutionContext context)
prettyPrint
- Whether to write the JSON using indentation and new lines to make it easier to readprintStartDocumentBrace
- Whether to print a start document character ({) before outputting any cursor dataprintCommaAtStart
- Whether to print comma before outputting any cursor dataprintStartArrayBracket
- Whether to print an open array ([) character before outputting any cursor dataprintEndArrayBracket
- Whether to print an end array character (]) after outputting the cursor dataprintEndDocumentBrace
- Whether to print an end document character (}) after outputting the cursor dataname
- The name to print before declaring the array (null if there is no name)indent
- The indent to use if pretty printing. Default is 4 spacescloseDestination
- True if the cursor will close the underlying destination after printing closing textdestination
- Where to write the data to. Must be a StringBuffer, Writer, or Filecontext
- The Gloop Execution Context, Gloop maps this automaticallyCopyright © 2019. All rights reserved.