public class JsonSerializer
extends java.lang.Object
PrettyJsonSerializer
Modifier and Type | Class and Description |
---|---|
static class |
JsonSerializer.Defaults |
Modifier and Type | Field and Description |
---|---|
protected java.lang.String |
classMetadataName |
protected boolean |
deep |
protected java.lang.String[] |
excludedTypeNames |
protected java.lang.Class[] |
excludedTypes |
protected boolean |
excludeEmpty |
protected boolean |
excludeNulls |
protected java.util.Map<Path,TypeJsonSerializer> |
pathSerializersMap |
protected InExRules<Path,PathQuery,PathQuery> |
rules |
protected java.util.function.Function<java.lang.Object,TypeJsonSerializer> |
serializerResolver |
protected boolean |
strictStringEncoding |
protected TypeJsonSerializerMap |
typeSerializersMap |
Constructor and Description |
---|
JsonSerializer() |
Modifier and Type | Method and Description |
---|---|
static JsonSerializer |
create()
Static ctor.
|
JsonContext |
createJsonContext(java.lang.Appendable appendable)
Creates new JSON context.
|
static PrettyJsonSerializer |
createPrettyOne()
Static ctor for
PrettyJsonSerializer . |
JsonSerializer |
deep(boolean includeCollections)
Defines if collections should be followed, i.e. to perform
deep serialization.
|
JsonSerializer |
exclude(boolean includeParent,
java.lang.String... excludes)
Adds excludes with optional parent including.
|
JsonSerializer |
exclude(java.lang.String... excludes)
Adds a list of excluded path queries.
|
JsonSerializer |
exclude(java.lang.String exclude)
Adds exclude path query.
|
JsonSerializer |
excludeEmpty(boolean excludeEmpty)
Excludes empty maps and collections.
|
JsonSerializer |
excludeNulls(boolean excludeNulls)
Excludes
null values while serializing. |
JsonSerializer |
excludeTypes(java.lang.Class... types)
Excludes types.
|
JsonSerializer |
excludeTypes(java.lang.String... typeNames)
Excludes type names.
|
JsonSerializer |
include(java.lang.String... includes)
Adds a list of included path queries.
|
JsonSerializer |
include(java.lang.String include)
Adds include path query.
|
JsonSerializer |
onValue(java.util.function.Function<java.lang.Object,TypeJsonSerializer> function)
Defines callback for value serialization.
|
java.lang.String |
serialize(java.lang.Object source)
Serializes object into source.
|
void |
serialize(java.lang.Object source,
java.lang.Appendable target)
Serializes object into provided appendable.
|
java.lang.CharSequence |
serializeToCharSequence(java.lang.Object source)
Serializes the object, but returns the
CharSequence . |
JsonSerializer |
setClassMetadataName(java.lang.String name)
Sets local class meta-data name.
|
JsonSerializer |
strictStringEncoding(boolean strictStringEncoding)
Specifies strict string encoding.
|
JsonSerializer |
withClassMetadata(boolean useMetadata)
Sets local class meta-data name.
|
JsonSerializer |
withSerializer(java.lang.Class type,
TypeJsonSerializer typeJsonSerializer)
Defines custom
TypeJsonSerializer for given type. |
JsonSerializer |
withSerializer(java.lang.String pathString,
TypeJsonSerializer typeJsonSerializer)
Defines custom
TypeJsonSerializer for given path. |
protected java.util.Map<Path,TypeJsonSerializer> pathSerializersMap
protected TypeJsonSerializerMap typeSerializersMap
protected java.lang.String classMetadataName
protected boolean strictStringEncoding
protected boolean deep
protected java.lang.Class[] excludedTypes
protected java.lang.String[] excludedTypeNames
protected boolean excludeNulls
protected boolean excludeEmpty
protected java.util.function.Function<java.lang.Object,TypeJsonSerializer> serializerResolver
public static JsonSerializer create()
public static PrettyJsonSerializer createPrettyOne()
PrettyJsonSerializer
.public JsonSerializer withSerializer(java.lang.String pathString, TypeJsonSerializer typeJsonSerializer)
TypeJsonSerializer
for given path.public JsonSerializer withSerializer(java.lang.Class type, TypeJsonSerializer typeJsonSerializer)
TypeJsonSerializer
for given type.public JsonSerializer include(java.lang.String include)
public JsonSerializer include(java.lang.String... includes)
public JsonSerializer exclude(java.lang.String exclude)
public JsonSerializer exclude(java.lang.String... excludes)
public JsonSerializer exclude(boolean includeParent, java.lang.String... excludes)
public JsonSerializer setClassMetadataName(java.lang.String name)
public JsonSerializer withClassMetadata(boolean useMetadata)
public JsonSerializer deep(boolean includeCollections)
public JsonSerializer excludeTypes(java.lang.String... typeNames)
InputStream
.
You can use wildcards to describe type names.public JsonSerializer excludeTypes(java.lang.Class... types)
public JsonSerializer excludeNulls(boolean excludeNulls)
null
values while serializing.public JsonSerializer excludeEmpty(boolean excludeEmpty)
public JsonSerializer strictStringEncoding(boolean strictStringEncoding)
public JsonSerializer onValue(java.util.function.Function<java.lang.Object,TypeJsonSerializer> function)
TypeJsonSerializer
to be used with the value. If null
is returned, default serializer will be resolved.public void serialize(java.lang.Object source, java.lang.Appendable target)
public java.lang.String serialize(java.lang.Object source)
public java.lang.CharSequence serializeToCharSequence(java.lang.Object source)
CharSequence
.public JsonContext createJsonContext(java.lang.Appendable appendable)
Copyright © 2003-present Jodd Team