Class JsonSerializer
java.lang.Object
jodd.json.JsonSerializer
- Direct Known Subclasses:
PrettyJsonSerializer
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected booleanprotected String[]protected Class[]protected booleanprotected booleanprotected Map<Path, TypeJsonSerializer> protected Function<Object, TypeJsonSerializer> protected booleanprotected TypeJsonSerializerMap -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic JsonSerializercreate()Static ctor.createJsonContext(Appendable appendable) Creates new JSON context.static PrettyJsonSerializerStatic ctor forPrettyJsonSerializer.deep(boolean includeCollections) Defines if collections should be followed, i.e.Adds excludes with optional parent including.Adds exclude path query.Adds a list of excluded path queries.excludeEmpty(boolean excludeEmpty) Excludes empty maps and collections.excludeNulls(boolean excludeNulls) Excludesnullvalues while serializing.excludeTypes(Class... types) Excludes types.excludeTypes(String... typeNames) Excludes type names.Adds include path query.Adds a list of included path queries.onValue(Function<Object, TypeJsonSerializer> function) Defines callback for value serialization.Serializes object into source.voidserialize(Object source, Appendable target) Serializes object into provided appendable.setClassMetadataName(String name) Sets local class meta-data name.strictStringEncoding(boolean strictStringEncoding) Specifies strict string encoding.withClassMetadata(boolean useMetadata) Sets local class meta-data name.withSerializer(Class type, TypeJsonSerializer typeJsonSerializer) Defines customTypeJsonSerializerfor given type.withSerializer(String pathString, TypeJsonSerializer typeJsonSerializer) Defines customTypeJsonSerializerfor given path.
-
Field Details
-
pathSerializersMap
-
typeSerializersMap
-
rules
-
classMetadataName
-
strictStringEncoding
protected boolean strictStringEncoding -
deep
protected boolean deep -
excludedTypes
-
excludedTypeNames
-
excludeNulls
protected boolean excludeNulls -
excludeEmpty
protected boolean excludeEmpty -
serializerResolver
-
-
Constructor Details
-
JsonSerializer
public JsonSerializer()
-
-
Method Details
-
create
Static ctor. -
createPrettyOne
Static ctor forPrettyJsonSerializer. -
withSerializer
Defines customTypeJsonSerializerfor given path. -
withSerializer
Defines customTypeJsonSerializerfor given type. -
include
Adds include path query. -
include
Adds a list of included path queries. -
exclude
Adds exclude path query. -
exclude
Adds a list of excluded path queries. -
exclude
Adds excludes with optional parent including. When parents are included, for each exclude query its parent will be included. For example, exclude of 'aaa.bb.ccc' would include it's parent: 'aaa.bb'. -
setClassMetadataName
Sets local class meta-data name. -
withClassMetadata
Sets local class meta-data name. -
deep
Defines if collections should be followed, i.e. to perform deep serialization. -
excludeTypes
Excludes type names. You can disable serialization of properties that are of some type. For example, you can disable properties ofInputStream. You can use wildcards to describe type names. -
excludeTypes
Excludes types. Supports interfaces and subclasses as well. -
excludeNulls
Excludesnullvalues while serializing. -
excludeEmpty
Excludes empty maps and collections. -
strictStringEncoding
Specifies strict string encoding. -
onValue
Defines callback for value serialization. It defines the instance ofTypeJsonSerializerto be used with the value. Ifnullis returned, default serializer will be resolved. -
serialize
Serializes object into provided appendable. -
serialize
-
createJsonContext
Creates new JSON context.
-