It currently has the following configuration methods, but more methods might be added in the future:
GsonBuilder#setFormattingStyle(FormattingStyle), JsonWriter#setFormattingStyle(FormattingStyle), Wikipedia Newline article
| Modifier and Type | Field and Description |
|---|---|
| public static final FormattingStyle | |
| private final String | |
| private final String | |
| public static final FormattingStyle | PRETTY
The default pretty printing formatting style:
|
| private final boolean |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public String | |
| public String | |
| public boolean | |
| public FormattingStyle | Returns: a newly createdFormattingStylethe string value that will be used as indent. indent)Creates a |
| public FormattingStyle | Returns: a newly createdFormattingStylethe string value that will be used as newline. newline)Creates a |
| public FormattingStyle | Returns: a newly createdFormattingStylewhether to output a space after spaceAfterSeparators)',' and ':'.Creates a |
| COMPACT | back to summary |
|---|---|
| public static final FormattingStyle COMPACT The default compact formatting style:
| |
| indent | back to summary |
|---|---|
| private final String indent | |
| newline | back to summary |
|---|---|
| private final String newline | |
| PRETTY | back to summary |
|---|---|
| public static final FormattingStyle PRETTY The default pretty printing formatting style:
| |
| spaceAfterSeparators | back to summary |
|---|---|
| private final boolean spaceAfterSeparators | |
| FormattingStyle | back to summary |
|---|---|
| private FormattingStyle(String newline, String indent, boolean spaceAfterSeparators) | |
| getIndent | back to summary |
|---|---|
| public String getIndent() Returns the string value that will be used as indent.
| |
| getNewline | back to summary |
|---|---|
| public String getNewline() Returns the string value that will be used as a newline.
| |
| usesSpaceAfterSeparators | back to summary |
|---|---|
| public boolean usesSpaceAfterSeparators() Returns whether a space will be used after
| |
| withIndent | back to summary |
|---|---|
| public FormattingStyle withIndent(String indent) Creates a Only combinations of spaces and tabs are allowed in indent.
| |
| withNewline | back to summary |
|---|---|
| public FormattingStyle withNewline(String newline) Creates a It can be used to accommodate certain OS convention, for example hardcode Only combinations of
| |
| withSpaceAfterSeparators | back to summary |
|---|---|
| public FormattingStyle withSpaceAfterSeparators(boolean spaceAfterSeparators) Creates a This setting has no effect on the configured newline. If a
non-empty newline is configured, it will always be added after
| |