java.lang.Object
org.jooq.JSONFormat
A JSON formatting type, which can be used to configure JSON imports /
exports.
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
Nested ClassesModifier and TypeClassDescriptionstatic enumThe format of binary values in JSON documents.static enumThe format ofnullvalues in JSON objects or arrays.static enumThe format of individual JSON records.static enumThe format of values, in case aConverteris present. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal @NotNull JSONFormat.NullFormatThe null format to be applied to arrays, defaulting toJSONFormat.NullFormat.NULL_ON_NULL.final @NotNull JSONFormatarrayNulls(JSONFormat.NullFormat newArrayNulls) The null format to be applied to arrays, defaulting toJSONFormat.NullFormat.NULL_ON_NULL.final JSONFormat.BinaryFormatTheJSONFormat.BinaryFormatto use when formatting binary data.final @NotNull JSONFormatbinaryFormat(JSONFormat.BinaryFormat newBinaryFormat) TheJSONFormat.BinaryFormatto use when formatting binary data.final booleanformat()The formatting flag.final @NotNull JSONFormatformat(boolean newFormat) The new value for the formatting flag, defaulting tofalse.final intThe global indentation applied on all levels.final @NotNull JSONFormatglobalIndent(int newGlobalIndent) The new global indentation size applied on all levels, defaulting to0.final booleanheader()Whether to emit a header row with column names, defaulting totrue.final @NotNull JSONFormatheader(boolean newHeader) Whether to emit a header row with column names, defaulting totrue.final intindent()The indentation size per level.final @NotNull JSONFormatindent(int newIndent) The new indentation size per level value, defaulting to2.final @NotNull StringindentString(int level) Convenience method to get an indentation string at a given level.final booleanWhetherDouble.POSITIVE_INFINITY,Double.NEGATIVE_INFINITY,Float.POSITIVE_INFINITY, andFloat.NEGATIVE_INFINITYvalues should be formatted as"Infinity"or"-Infinity"strings.final @NotNull JSONFormatinfinityAsString(boolean newInfinityAsString) WhetherDouble.POSITIVE_INFINITY,Double.NEGATIVE_INFINITY,Float.POSITIVE_INFINITY, andFloat.NEGATIVE_INFINITYvalues should be formatted as"Infinity"or"-Infinity"strings.final booleanmutable()Whether this configuration object is mutable.final @NotNull JSONFormatmutable(boolean newMutable) The new value for the mutable flag, defaulting tofalse.final booleanfinal @NotNull JSONFormatnanAsString(boolean newNanAsString) final @NotNull Stringnewline()The formatting flag.final @NotNull JSONFormatThe new newline character, defaulting to\n.final @NotNull JSONFormat.NullFormatThe null format to be applied to objects, defaulting toJSONFormat.NullFormat.NULL_ON_NULL.final @NotNull JSONFormatobjectNulls(JSONFormat.NullFormat newObjectNulls) The null format to be applied to objects, defaulting toJSONFormat.NullFormat.NULL_ON_NULL.final booleanfinal @NotNull JSONFormatquoteNested(boolean newQuoteNested) final @NotNull JSONFormat.RecordFormatThe record format to be applied, defaulting toJSONFormat.RecordFormat.ARRAY.final @NotNull JSONFormatrecordFormat(JSONFormat.RecordFormat newRecordFormat) The record format to be applied, defaulting toJSONFormat.RecordFormat.ARRAY.final Stringredacted()The string value to show for redacted content.final @NotNull JSONFormatThe string value to show for redacted content.final @NotNull JSONFormat.ValueFormatThe value format to be applied, defaulting toJSONFormat.ValueFormat.TO_TYPE.final @NotNull JSONFormatvalueFormat(JSONFormat.ValueFormat newValueFormat) The value format to be applied, defaulting toJSONFormat.ValueFormat.TO_TYPE.final booleanWhether to wrap single column records in therecordFormat().final @NotNull JSONFormatwrapSingleColumnRecords(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
-
mutable
public final boolean mutable()Whether this configuration object is mutable. -
mutable
The new value for the mutable flag, defaulting tofalse. -
redacted
The string value to show for redacted content. -
redacted
The string value to show for redacted content. -
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. -
valueFormat
The value format to be applied, defaulting toJSONFormat.ValueFormat.TO_TYPE. -
valueFormat
The value format to be applied, defaulting toJSONFormat.ValueFormat.TO_TYPE. -
recordFormat
The record format to be applied, defaulting toJSONFormat.RecordFormat.ARRAY. -
recordFormat
The record format to be applied, defaulting toJSONFormat.RecordFormat.ARRAY. -
objectNulls
The null format to be applied to objects, defaulting toJSONFormat.NullFormat.NULL_ON_NULL. -
objectNulls
The null format to be applied to objects, defaulting toJSONFormat.NullFormat.NULL_ON_NULL. -
arrayNulls
The null format to be applied to arrays, defaulting toJSONFormat.NullFormat.NULL_ON_NULL. -
arrayNulls
The null format to be applied to arrays, defaulting toJSONFormat.NullFormat.NULL_ON_NULL. -
wrapSingleColumnRecords
@NotNull public final @NotNull 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
-
quoteNested
public final boolean quoteNested() -
nanAsString
WhetherDouble.NaNandFloat.NaNvalues should be formatted as"NaN"strings. The default is to format them asnull, as JSON doesn't supportNaNvalues. -
nanAsString
public final boolean nanAsString()WhetherDouble.NaNandFloat.NaNvalues should be formatted as"NaN"strings. The default is to format them asnull, as JSON doesn't supportNaNvalues. -
infinityAsString
WhetherDouble.POSITIVE_INFINITY,Double.NEGATIVE_INFINITY,Float.POSITIVE_INFINITY, andFloat.NEGATIVE_INFINITYvalues should be formatted as"Infinity"or"-Infinity"strings. The default is to format them asnull, as JSON doesn't supportInfinityvalues. -
infinityAsString
public final boolean infinityAsString()WhetherDouble.POSITIVE_INFINITY,Double.NEGATIVE_INFINITY,Float.POSITIVE_INFINITY, andFloat.NEGATIVE_INFINITYvalues should be formatted as"Infinity"or"-Infinity"strings. The default is to format them asnull, as JSON doesn't supportInfinityvalues. -
binaryFormat
TheJSONFormat.BinaryFormatto use when formatting binary data. -
binaryFormat
TheJSONFormat.BinaryFormatto use when formatting binary data.
-