- java.lang.Object
-
- org.jooq.JSONFormat
-
public final class JSONFormat extends Object
A JSON formatting type, which can be used to configure JSON imports / exports.The default format is the following, using
header()
equal totrue
and applyingJSONFormat.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 tofalse
, then the result is simply the records array, either usingJSONFormat.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}]
- Author:
- Lukas Eder
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JSONFormat.RecordFormat
The format of individual JSON records.
-
Field Summary
Fields Modifier and Type Field Description static JSONFormat
DEFAULT_FOR_RECORDS
static JSONFormat
DEFAULT_FOR_RESULTS
-
Constructor Summary
Constructors Constructor Description JSONFormat()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
format()
The formatting flag.JSONFormat
format(boolean newFormat)
The new value for the formatting flag, defaulting tofalse
.boolean
header()
Whether to emit a header row with column names, defaulting totrue
.JSONFormat
header(boolean newHeader)
Whether to emit a header row with column names, defaulting totrue
.int
indent()
The indentation.JSONFormat
indent(int newIndent)
The new indentation value, defaulting to2
.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 toJSONFormat.RecordFormat.ARRAY
.JSONFormat
recordFormat(JSONFormat.RecordFormat newRecordFormat)
The record format to be applied, defaulting toJSONFormat.RecordFormat.ARRAY
.boolean
wrapSingleColumnRecords()
Whether to wrap single column records in therecordFormat()
.JSONFormat
wrapSingleColumnRecords(boolean newWrapSingleColumnRecords)
Whether to wrap single column records in therecordFormat()
.
-
-
-
Field Detail
-
DEFAULT_FOR_RESULTS
public static final JSONFormat DEFAULT_FOR_RESULTS
-
DEFAULT_FOR_RECORDS
public static final JSONFormat DEFAULT_FOR_RECORDS
-
-
Method Detail
-
format
public final JSONFormat format(boolean newFormat)
The new value for the formatting flag, defaulting tofalse
.
-
format
public final boolean format()
The formatting flag.
-
newline
public final JSONFormat newline(String newNewline)
The new newline character, defaulting to\n
.
-
newline
public final String newline()
The formatting flag.
-
indent
public final JSONFormat indent(int newIndent)
The new indentation value, defaulting to2
.
-
indent
public final int indent()
The indentation.
-
indentString
public final String indentString(int level)
Convenience method to get an indentation string at a given level.
-
header
public final JSONFormat header(boolean newHeader)
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
public final JSONFormat recordFormat(JSONFormat.RecordFormat newRecordFormat)
The record format to be applied, defaulting toJSONFormat.RecordFormat.ARRAY
.
-
recordFormat
public final JSONFormat.RecordFormat recordFormat()
The record format to be applied, defaulting toJSONFormat.RecordFormat.ARRAY
.
-
wrapSingleColumnRecords
public final JSONFormat wrapSingleColumnRecords(boolean newWrapSingleColumnRecords)
Whether to wrap single column records in therecordFormat()
.
-
wrapSingleColumnRecords
public final boolean wrapSingleColumnRecords()
Whether to wrap single column records in therecordFormat()
.
-
quoteNested
public final JSONFormat quoteNested(boolean newQuoteNested)
-
quoteNested
public final boolean quoteNested()
-
-