Package uk.blankaspect.common.json
Class JsonGenerator.Builder
java.lang.Object
uk.blankaspect.common.json.JsonGenerator.Builder
- Enclosing class:
JsonGenerator
This class implements a builder for a JSON generator.
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Creates and returns a new instance of a JSON generator that is initialised from the state of this builder.indentIncrement
(int indentIncrement) Sets the number of spaces by which indentation is increased from one level to the next.maxLineLength
(int maxLineLength) Sets the maximum length of a line of JSON text without wrapping.newLineBeforeLeftBracket
(NewLineBeforeLeftBracket newLineBeforeLeftBracket) Sets the circumstance in which a new line is written before the opening bracket of a JSON array or the opening brace of a JSON object.outputMode
(OutputMode outputMode) Sets the way in which whitespace is written between the tokens of the JSON text.printableAsciiOnly
(boolean printableAsciiOnly) Sets the flag that determines whether JSON string values and the names of the members of JSON objects will be escaped so that they contain only printable characters from the US-ASCII character encoding (ie, characters in the range U+0020 to U+007E inclusive).
-
Method Details
-
outputMode
Sets the way in which whitespace is written between the tokens of the JSON text. The default value isNORMAL
.- Parameters:
outputMode
- the way in which whitespace is written between the tokens of the JSON text.- Returns:
- this builder.
-
newLineBeforeLeftBracket
public JsonGenerator.Builder newLineBeforeLeftBracket(NewLineBeforeLeftBracket newLineBeforeLeftBracket) Sets the circumstance in which a new line is written before the opening bracket of a JSON array or the opening brace of a JSON object. The default value isEXCEPT_AFTER_NAME
.- Parameters:
newLineBeforeLeftBracket
- the circumstance in which a new line is written before the opening bracket of a JSON array or the opening brace of a JSON object.- Returns:
- this builder.
-
indentIncrement
Sets the number of spaces by which indentation is increased from one level to the next. The default value is 2.- Parameters:
indentIncrement
- the number of spaces by which indentation is increased from one level to the next.- Returns:
- this builder.
-
maxLineLength
Sets the maximum length of a line of JSON text without wrapping. The default value is 96.- Parameters:
maxLineLength
- the maximum length of a line of JSON text without wrapping.- Returns:
- this builder.
-
printableAsciiOnly
Sets the flag that determines whether JSON string values and the names of the members of JSON objects will be escaped so that they contain only printable characters from the US-ASCII character encoding (ie, characters in the range U+0020 to U+007E inclusive). The default value istrue
.- Parameters:
printableAsciiOnly
- iftrue
, the values of JSON strings and the names of the members of JSON objects will be escaped so that they contain only printable characters from the US-ASCII character encoding.- Returns:
- this builder.
-
build
Creates and returns a new instance of a JSON generator that is initialised from the state of this builder.- Returns:
- a new instance of a JSON generator.
-