public static class JsonSerializationContext.Builder extends Object
| Constructor and Description |
|---|
JsonSerializationContext.Builder() |
| Modifier and Type | Method and Description |
|---|---|
JsonSerializationContext |
build() |
JsonSerializationContext.Builder |
indent(boolean indent)
Feature that allows enabling (or disabling) indentation
for the underlying writer.
|
JsonSerializationContext.Builder |
orderMapEntriesByKeys(boolean orderMapEntriesByKeys)
|
JsonSerializationContext.Builder |
serializeNulls(boolean serializeNulls)
Sets whether object members are serialized when their value is null.
|
JsonSerializationContext.Builder |
useEqualityForObjectId(boolean useEqualityForObjectId)
Determines whether Object Identity is compared using
true JVM-level identity of Object (false); or,
equals() method. |
JsonSerializationContext.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).
|
JsonSerializationContext.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). |
JsonSerializationContext.Builder |
writeDateKeysAsTimestamps(boolean writeDateKeysAsTimestamps)
|
JsonSerializationContext.Builder |
writeDatesAsTimestamps(boolean writeDatesAsTimestamps)
|
JsonSerializationContext.Builder |
writeEmptyJsonArrays(boolean writeEmptyJsonArrays)
Feature that determines whether Container properties (POJO properties
with declared value of Collection or array; i.e.
|
JsonSerializationContext.Builder |
writeNullMapValues(boolean writeNullMapValues)
Feature that determines whether Map entries with null values are
to be serialized (true) or not (false).
|
JsonSerializationContext.Builder |
writeSingleElemArraysUnwrapped(boolean writeSingleElemArraysUnwrapped)
Feature added for interoperability, to work with oddities of
so-called "BadgerFish" convention.
|
public JsonSerializationContext.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()public JsonSerializationContext.Builder serializeNulls(boolean serializeNulls)
public JsonSerializationContext.Builder writeDatesAsTimestamps(boolean writeDatesAsTimestamps)
public JsonSerializationContext.Builder writeDateKeysAsTimestamps(boolean writeDateKeysAsTimestamps)
public JsonSerializationContext.Builder indent(boolean indent)
Feature is disabled by default.
public JsonSerializationContext.Builder wrapRootValue(boolean wrapRootValue)
Feature is disabled by default.
public JsonSerializationContext.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.public JsonSerializationContext.Builder writeNullMapValues(boolean writeNullMapValues)
public JsonSerializationContext.Builder writeEmptyJsonArrays(boolean writeEmptyJsonArrays)
Maps, or
"Collection-like" types.
Feature is enabled by default.public JsonSerializationContext.Builder orderMapEntriesByKeys(boolean orderMapEntriesByKeys)
public JsonSerializationContext.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.
When enabled, a POJO with array that normally looks like this:
{ "arrayProperty" : [ 1 ] }
will instead be serialized as
{ "arrayProperty" : 1 }
Note that this feature is counterpart to JsonDeserializationContext.Builder.acceptSingleValueAsArray(boolean)
(that is, usually both are enabled, or neither is).
Feature is disabled by default, so that no special handling is done.public JsonSerializationContext build()
Copyright © 2013. All Rights Reserved.