public static class DefaultJsonSerializationContext.Builder extends Object
JsonSerializationContext. To override default settings globally, you can extend this class, modify the
default settings inside the constructor and tell the compiler to use your builder instead in your gwt.xml file :
<replace-with class="your.package.YourBuilder">
<when-type-assignable class="org.dominokit.jacksonapt.JsonSerializationContext.Builder" />
</replace-with>
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
indent |
protected boolean |
orderMapEntriesByKeys |
protected boolean |
serializeNulls |
protected boolean |
useEqualityForObjectId |
protected boolean |
wrapExceptions |
protected boolean |
wrapRootValue |
protected boolean |
writeCharArraysAsJsonArrays |
protected boolean |
writeDateKeysAsTimestamps |
protected boolean |
writeDatesAsTimestamps |
protected boolean |
writeEmptyJsonArrays |
protected boolean |
writeNullMapValues |
protected boolean |
writeSingleElemArraysUnwrapped |
| Constructor and Description |
|---|
Builder()
Deprecated.
Use
DefaultJsonSerializationContext.builder() instead. This constructor will be made protected in v1.0. |
| Modifier and Type | Method and Description |
|---|---|
JsonSerializationContext |
build() |
DefaultJsonSerializationContext.Builder |
indent(boolean indent)
Feature that allows enabling (or disabling) indentation
for the underlying writer.
|
DefaultJsonSerializationContext.Builder |
orderMapEntriesByKeys(boolean orderMapEntriesByKeys)
|
DefaultJsonSerializationContext.Builder |
serializeNulls(boolean serializeNulls)
Sets whether object members are serialized when their value is null.
|
DefaultJsonSerializationContext.Builder |
useEqualityForObjectId(boolean useEqualityForObjectId)
Determines whether Object Identity is compared using
true JVM-level identity of Object (false); or,
equals() method. |
DefaultJsonSerializationContext.Builder |
wrapExceptions(boolean wrapExceptions)
Feature that determines whether gwt-jackson code should catch
and wrap
RuntimeExceptions (but never Errors!)
to add additional information about
location (within input) of problem or not. |
DefaultJsonSerializationContext.Builder |
wrapRootValue(boolean wrapRootValue)
Feature that can be enabled to make root value (usually JSON
Object but can be any type) wrapped within a single property
JSON object, where key as the "root name", as determined by
annotation introspector or fallback (non-qualified
class name).
|
DefaultJsonSerializationContext.Builder |
writeCharArraysAsJsonArrays(boolean writeCharArraysAsJsonArrays)
Feature that determines how type
char[] is serialized:
when enabled, will be serialized as an explict JSON array (with
single-character Strings as values); when disabled, defaults to
serializing them as Strings (which is more compact). |
DefaultJsonSerializationContext.Builder |
writeDateKeysAsTimestamps(boolean writeDateKeysAsTimestamps)
|
DefaultJsonSerializationContext.Builder |
writeDatesAsTimestamps(boolean writeDatesAsTimestamps)
|
DefaultJsonSerializationContext.Builder |
writeEmptyJsonArrays(boolean writeEmptyJsonArrays)
Feature that determines whether Container properties (POJO properties
with declared value of Collection or array; i.e.
|
DefaultJsonSerializationContext.Builder |
writeNullMapValues(boolean writeNullMapValues)
Feature that determines whether Map entries with null values are
to be serialized (true) or not (false).
|
DefaultJsonSerializationContext.Builder |
writeSingleElemArraysUnwrapped(boolean writeSingleElemArraysUnwrapped)
Feature added for interoperability, to work with oddities of
so-called "BadgerFish" convention.
|
protected boolean useEqualityForObjectId
protected boolean serializeNulls
protected boolean writeDatesAsTimestamps
protected boolean writeDateKeysAsTimestamps
protected boolean indent
protected boolean wrapRootValue
protected boolean writeCharArraysAsJsonArrays
protected boolean writeNullMapValues
protected boolean writeEmptyJsonArrays
protected boolean orderMapEntriesByKeys
protected boolean writeSingleElemArraysUnwrapped
protected boolean wrapExceptions
@Deprecated public Builder()
DefaultJsonSerializationContext.builder() instead. This constructor will be made protected in v1.0.public DefaultJsonSerializationContext.Builder useEqualityForObjectId(boolean useEqualityForObjectId)
equals() method.
Latter is sometimes useful when dealing with Database-bound objects with
ORM libraries (like Hibernate).
Option is disabled by default; meaning that strict identity is used, not
equals()
useEqualityForObjectId - true if should useEqualityForObjectIdpublic DefaultJsonSerializationContext.Builder serializeNulls(boolean serializeNulls)
serializeNulls - true if should serializeNullspublic DefaultJsonSerializationContext.Builder writeDatesAsTimestamps(boolean writeDatesAsTimestamps)
Date and Timestamp values are to be serialized as numeric timestamps
(true; the default), or as textual representation.
If textual representation is used, the actual format is Option is enabled by default.
writeDatesAsTimestamps - true if should writeDatesAsTimestampspublic DefaultJsonSerializationContext.Builder writeDateKeysAsTimestamps(boolean writeDateKeysAsTimestamps)
Dates and Timestamps used as Map keys are
serialized as timestamps or as textual values.
If textual representation is used, the actual format is Option is disabled by default.
writeDateKeysAsTimestamps - true if should writeDateKeysAsTimestampspublic DefaultJsonSerializationContext.Builder indent(boolean indent)
Feature is disabled by default.
indent - true if should indentpublic DefaultJsonSerializationContext.Builder wrapRootValue(boolean wrapRootValue)
Feature is disabled by default.
wrapRootValue - true if should wrapRootValuepublic DefaultJsonSerializationContext.Builder writeCharArraysAsJsonArrays(boolean writeCharArraysAsJsonArrays)
char[] is serialized:
when enabled, will be serialized as an explict JSON array (with
single-character Strings as values); when disabled, defaults to
serializing them as Strings (which is more compact).
Feature is disabled by default.
writeCharArraysAsJsonArrays - true if should writeCharArraysAsJsonArrayspublic DefaultJsonSerializationContext.Builder writeNullMapValues(boolean writeNullMapValues)
Feature is enabled by default.
writeNullMapValues - true if should writeNullMapValuespublic DefaultJsonSerializationContext.Builder writeEmptyJsonArrays(boolean writeEmptyJsonArrays)
Note that this does not change behavior of Maps, or
"Collection-like" types.
Feature is enabled by default.
writeEmptyJsonArrays - true if should writeEmptyJsonArrayspublic DefaultJsonSerializationContext.Builder orderMapEntriesByKeys(boolean orderMapEntriesByKeys)
Map entries are first
sorted by key before serialization or not: if enabled, additional sorting
step is performed if necessary (not necessary for SortedMaps),
if disabled, no additional sorting is needed.
Feature is disabled by default.
orderMapEntriesByKeys - true if should orderMapEntriesByKeyspublic DefaultJsonSerializationContext.Builder writeSingleElemArraysUnwrapped(boolean writeSingleElemArraysUnwrapped)
Collections
and arrays: if enabled, Collections and arrays that contain exactly
one element will be serialized as if that element itself was serialized.
{ "arrayProperty" : [ 1 ] }
will instead be serialized as
{ "arrayProperty" : 1 }
Note that this feature is counterpart to DefaultJsonDeserializationContext.Builder.acceptSingleValueAsArray(boolean)
(that is, usually both are enabled, or neither is).
writeSingleElemArraysUnwrapped - true if should writeSingleElemArraysUnwrappedpublic DefaultJsonSerializationContext.Builder wrapExceptions(boolean wrapExceptions)
RuntimeExceptions (but never Errors!)
to add additional information about
location (within input) of problem or not. If enabled,
exceptions will be caught and re-thrown; this can be
convenient both in that all exceptions will be checked and
declared, and so there is more contextual information.
However, sometimes calling application may just want "raw"
unchecked exceptions passed as is.
wrapExceptions - true if should wrapExceptionspublic final JsonSerializationContext build()
Copyright © 2020. All rights reserved.