public final class JSONFormat extends Object
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}]
Modifier and Type | Class and Description |
---|---|
static class |
JSONFormat.RecordFormat
The format of individual JSON records.
|
Modifier and Type | Field and Description |
---|---|
static JSONFormat |
DEFAULT_FOR_RECORDS |
static JSONFormat |
DEFAULT_FOR_RESULTS |
Constructor and Description |
---|
JSONFormat() |
Modifier and Type | Method and Description |
---|---|
boolean |
format()
The formatting flag.
|
JSONFormat |
format(boolean newFormat)
The new value for the formatting flag, defaulting to
false . |
boolean |
header()
Whether to emit a header row with column names, defaulting to
true . |
JSONFormat |
header(boolean newHeader)
Whether to emit a header row with column names, defaulting to
true . |
int |
indent()
The indentation.
|
JSONFormat |
indent(int newIndent)
The new indentation value, defaulting to
2 . |
String |
indentString(int level)
Convenience method to get an indentation string at a given level.
|
String |
newline()
The formatting flag.
|
JSONFormat |
newline(String newNewline)
The new newline character, defaulting to
\n . |
boolean |
quoteNested()
|
JSONFormat |
quoteNested(boolean newQuoteNested)
|
JSONFormat.RecordFormat |
recordFormat()
The record format to be applied, defaulting to
JSONFormat.RecordFormat.ARRAY . |
JSONFormat |
recordFormat(JSONFormat.RecordFormat newRecordFormat)
The record format to be applied, defaulting to
JSONFormat.RecordFormat.ARRAY . |
boolean |
wrapSingleColumnRecords()
Whether to wrap single column records in the
recordFormat() . |
JSONFormat |
wrapSingleColumnRecords(boolean newWrapSingleColumnRecords)
Whether to wrap single column records in the
recordFormat() . |
public static final JSONFormat DEFAULT_FOR_RESULTS
public static final JSONFormat DEFAULT_FOR_RECORDS
public final JSONFormat format(boolean newFormat)
false
.public final boolean format()
public final JSONFormat newline(String newNewline)
\n
.public final String newline()
public final JSONFormat indent(int newIndent)
2
.public final int indent()
public final String indentString(int level)
public final JSONFormat header(boolean newHeader)
true
.public final boolean header()
true
.public final JSONFormat recordFormat(JSONFormat.RecordFormat newRecordFormat)
JSONFormat.RecordFormat.ARRAY
.public final JSONFormat.RecordFormat recordFormat()
JSONFormat.RecordFormat.ARRAY
.public final JSONFormat wrapSingleColumnRecords(boolean newWrapSingleColumnRecords)
recordFormat()
.public final boolean wrapSingleColumnRecords()
recordFormat()
.public final JSONFormat quoteNested(boolean newQuoteNested)
public final boolean quoteNested()
Copyright © 2021. All rights reserved.