The default format is the following, using header()
equal to
true
and applying JSONFormat.RecordFormat.ARRAY
:
{"fields":[{"name":"field-1","type":"type-1"},
{"name":"field-2","type":"type-2"},
...,
{"name":"field-n","type":"type-n"}],
"records":[[value-1-1,value-1-2,...,value-1-n],
[value-2-1,value-2-2,...,value-2-n]]}
If header()
is set to false
, then the result is simply
the records array, either using JSONFormat.RecordFormat.ARRAY
:
[[value-1-1,value-1-2,...,value-1-n],
[value-2-1,value-2-2,...,value-2-n]]
or, using JSONFormat.RecordFormat.OBJECT
:
[{"field-1": value-1-1, "field-2": value-1-2,..., "field-n": value-1-n},
{"field-1": value-2-1, "field-2": value-2-2,..., "field-n": value-2-n}]
The type is immutable, meaning calls to setters like header(boolean)
do not modify the original reference, but return a new one instead.
- Author:
- Lukas Eder
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
The format of individual JSON records. -
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
format()
The formatting flag.format(boolean newFormat)
The new value for the formatting flag, defaulting tofalse
.int
The global indentation applied on all levels.globalIndent(int newGlobalIndent)
The new global indentation size applied on all levels, defaulting to0
.boolean
header()
Whether to emit a header row with column names, defaulting totrue
.header(boolean newHeader)
Whether to emit a header row with column names, defaulting totrue
.int
indent()
The indentation size per level.indent(int newIndent)
The new indentation size per level value, defaulting to2
.indentString(int level)
Convenience method to get an indentation string at a given level.newline()
The formatting flag.The new newline character, defaulting to\n
.boolean
quoteNested(boolean newQuoteNested)
The record format to be applied, defaulting toJSONFormat.RecordFormat.ARRAY
.recordFormat(JSONFormat.RecordFormat newRecordFormat)
The record format to be applied, defaulting toJSONFormat.RecordFormat.ARRAY
.boolean
Whether to wrap single column records in therecordFormat()
.wrapSingleColumnRecords(boolean newWrapSingleColumnRecords)
Whether to wrap single column records in therecordFormat()
.
-
Field Details
-
DEFAULT_FOR_RESULTS
-
DEFAULT_FOR_RECORDS
-
-
Constructor Details
-
JSONFormat
public JSONFormat()
-
-
Method Details
-
format
The new value for the formatting flag, defaulting tofalse
. -
format
public final boolean format()The formatting flag. -
newline
The new newline character, defaulting to\n
. -
newline
The formatting flag. -
globalIndent
The new global indentation size applied on all levels, defaulting to0
. -
globalIndent
public final int globalIndent()The global indentation applied on all levels. -
indent
The new indentation size per level value, defaulting to2
. -
indent
public final int indent()The indentation size per level. -
indentString
Convenience method to get an indentation string at a given level. -
header
Whether to emit a header row with column names, defaulting totrue
. -
header
public final boolean header()Whether to emit a header row with column names, defaulting totrue
. -
recordFormat
The record format to be applied, defaulting toJSONFormat.RecordFormat.ARRAY
. -
recordFormat
The record format to be applied, defaulting toJSONFormat.RecordFormat.ARRAY
. -
wrapSingleColumnRecords
Whether to wrap single column records in therecordFormat()
. -
wrapSingleColumnRecords
public final boolean wrapSingleColumnRecords()Whether to wrap single column records in therecordFormat()
. -
quoteNested
-
quoteNested
public final boolean quoteNested()
-