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 . |
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 . |
public static final JSONFormat DEFAULT_FOR_RESULTS
public static final JSONFormat DEFAULT_FOR_RECORDS
public JSONFormat format(boolean newFormat)
false
.public boolean format()
public JSONFormat newline(String newNewline)
\n
.public String newline()
public JSONFormat indent(int newIndent)
2
.public int indent()
public String indentString(int level)
public JSONFormat header(boolean newHeader)
true
.public boolean header()
true
.public JSONFormat recordFormat(JSONFormat.RecordFormat newRecordFormat)
JSONFormat.RecordFormat.ARRAY
.public JSONFormat.RecordFormat recordFormat()
JSONFormat.RecordFormat.ARRAY
.Copyright © 2019. All rights reserved.