Top Description Inners Fields Constructors Methods
org.jooq

public final Class JSONFormat

extends Object
Class Inheritance
Static Imports
org.jooq.tools.StringUtils.rightPad

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 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 RecordFormat#ARRAY:


[[value-1-1,value-1-2,...,value-1-n],
 [value-2-1,value-2-2,...,value-2-n]]

or, using 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 and Inner Type Summary

Modifier and TypeClass and Description
public static enum
JSONFormat.RecordFormat

The format of individual JSON records.

Field Summary

Modifier and TypeField and Description
public static final JSONFormat
public static final JSONFormat
pack-priv boolean
pack-priv int
pack-priv boolean
pack-priv int
pack-priv String[]
pack-priv final boolean
pack-priv String
pack-priv boolean
pack-priv JSONFormat.RecordFormat
pack-priv boolean

Constructor Summary

AccessConstructor and Description
public
private
JSONFormat(boolean mutable, boolean format, String newline, int globalIndent, int indent, String[] indented, boolean header, JSONFormat.RecordFormat recordFormat, boolean wrapSingleColumnRecords, boolean quoteNested)

Method Summary

Modifier and TypeMethod and Description
public final @NotNull JSONFormat
format(boolean newFormat)

The new value for the formatting flag, defaulting to false.

public final boolean
format()

The formatting flag.

public final @NotNull JSONFormat
globalIndent(int newGlobalIndent)

The new global indentation size applied on all levels, defaulting to 0.

public final int
globalIndent()

The global indentation applied on all levels.

public final @NotNull JSONFormat
header(boolean newHeader)

Whether to emit a header row with column names, defaulting to true.

public final boolean
header()

Whether to emit a header row with column names, defaulting to true.

public final @NotNull JSONFormat
indent(int newIndent)

The new indentation size per level value, defaulting to 2.

public final int
indent()

The indentation size per level.

public final @NotNull String
indentString(int level)

Convenience method to get an indentation string at a given level.

public final boolean
mutable()

Whether this configuration object is mutable.

public final @NotNull JSONFormat
mutable(boolean newMutable)

The new value for the mutable flag, defaulting to false.

public final @NotNull JSONFormat
newline(String newNewline)

The new newline character, defaulting to \n.

public final @NotNull String
newline()

The formatting flag.

public final @NotNull JSONFormat
quoteNested(boolean newQuoteNested)

Whether nested JSON or JSONB content should be quoted like a string, or nested into JSON formatted output.

public final boolean
quoteNested()

Whether nested JSON or JSONB content should be quoted like a string, or nested into JSON formatted output.

public final @NotNull JSONFormat
recordFormat(JSONFormat.RecordFormat newRecordFormat)

The record format to be applied, defaulting to RecordFormat#ARRAY.

public final @NotNull JSONFormat.RecordFormat
recordFormat()

The record format to be applied, defaulting to RecordFormat#ARRAY.

public final @NotNull JSONFormat
wrapSingleColumnRecords(boolean newWrapSingleColumnRecords)

Whether to wrap single column records in the recordFormat().

public final boolean
wrapSingleColumnRecords()

Whether to wrap single column records in the recordFormat().

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_FOR_RECORDSback to summary
public static final JSONFormat DEFAULT_FOR_RECORDS
DEFAULT_FOR_RESULTSback to summary
public static final JSONFormat DEFAULT_FOR_RESULTS
formatback to summary
pack-priv boolean format
globalIndentback to summary
pack-priv int globalIndent
indentback to summary
pack-priv int indent
indentedback to summary
pack-priv String[] indented
mutableback to summary
pack-priv final boolean mutable
newlineback to summary
pack-priv String newline
quoteNestedback to summary
pack-priv boolean quoteNested
recordFormatback to summary
pack-priv JSONFormat.RecordFormat recordFormat
wrapSingleColumnRecordsback to summary
pack-priv boolean wrapSingleColumnRecords

Constructor Detail

JSONFormatback to summary
public JSONFormat()
JSONFormatback to summary
private JSONFormat(boolean mutable, boolean format, String newline, int globalIndent, int indent, String[] indented, boolean header, JSONFormat.RecordFormat recordFormat, boolean wrapSingleColumnRecords, boolean quoteNested)

Method Detail

formatback to summary
public final @NotNull JSONFormat format(boolean newFormat)

The new value for the formatting flag, defaulting to false.

Annotations
@NotNull
formatback to summary
public final boolean format()

The formatting flag.

globalIndentback to summary
public final @NotNull JSONFormat globalIndent(int newGlobalIndent)

The new global indentation size applied on all levels, defaulting to 0.

Annotations
@NotNull
globalIndentback to summary
public final int globalIndent()

The global indentation applied on all levels.

headerback to summary
public final @NotNull JSONFormat header(boolean newHeader)

Whether to emit a header row with column names, defaulting to true.

Annotations
@NotNull
headerback to summary
public final boolean header()

Whether to emit a header row with column names, defaulting to true.

indentback to summary
public final @NotNull JSONFormat indent(int newIndent)

The new indentation size per level value, defaulting to 2.

Annotations
@NotNull
indentback to summary
public final int indent()

The indentation size per level.

indentStringback to summary
public final @NotNull String indentString(int level)

Convenience method to get an indentation string at a given level.

Annotations
@NotNull
mutableback to summary
public final boolean mutable()

Whether this configuration object is mutable.

mutableback to summary
public final @NotNull JSONFormat mutable(boolean newMutable)

The new value for the mutable flag, defaulting to false.

Annotations
@NotNull
newlineback to summary
public final @NotNull JSONFormat newline(String newNewline)

The new newline character, defaulting to \n.

Annotations
@NotNull
newlineback to summary
public final @NotNull String newline()

The formatting flag.

Annotations
@NotNull
quoteNestedback to summary
public final @NotNull JSONFormat quoteNested(boolean newQuoteNested)

Whether nested JSON or JSONB content should be quoted like a string, or nested into JSON formatted output.

Annotations
@NotNull
quoteNestedback to summary
public final boolean quoteNested()

Whether nested JSON or JSONB content should be quoted like a string, or nested into JSON formatted output.

recordFormatback to summary
public final @NotNull JSONFormat recordFormat(JSONFormat.RecordFormat newRecordFormat)

The record format to be applied, defaulting to RecordFormat#ARRAY.

Annotations
@NotNull
recordFormatback to summary
public final @NotNull JSONFormat.RecordFormat recordFormat()

The record format to be applied, defaulting to RecordFormat#ARRAY.

Annotations
@NotNull
wrapSingleColumnRecordsback to summary
public final @NotNull JSONFormat wrapSingleColumnRecords(boolean newWrapSingleColumnRecords)

Whether to wrap single column records in the recordFormat().

Annotations
@NotNull
wrapSingleColumnRecordsback to summary
public final boolean wrapSingleColumnRecords()

Whether to wrap single column records in the recordFormat().

org.jooq back to summary

public final Enum JSONFormat.RecordFormat

extends Enum<JSONFormat.RecordFormat>
Class Inheritance

The format of individual JSON records.

Field Summary

Modifier and TypeField and Description
public static final JSONFormat.RecordFormat
ARRAY

A record is a JSON array.

public static final JSONFormat.RecordFormat
OBJECT

A record is a JSON object.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static JSONFormat.RecordFormat
public static JSONFormat.RecordFormat[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ARRAYback to summary
public static final JSONFormat.RecordFormat ARRAY

A record is a JSON array.

This format allows for accessing columns by index, saving space by avoiding repetitive column names in large result sets. Use this preferrably with JSONFormat#header() equal to true.

OBJECTback to summary
public static final JSONFormat.RecordFormat OBJECT

A record is a JSON object.

This format allows for accessing columns by name, repeating column names in each record.

Constructor Detail

RecordFormatback to summary
private RecordFormat()

Method Detail

valueOfback to summary
public static JSONFormat.RecordFormat valueOf(String name)
valuesback to summary
public static JSONFormat.RecordFormat[] values()