Package org.apache.flink.formats.json
Class JsonSerializationSchema<T>
- java.lang.Object
-
- org.apache.flink.formats.json.JsonSerializationSchema<T>
-
- All Implemented Interfaces:
Serializable
,SerializationSchema<T>
@PublicEvolving public class JsonSerializationSchema<T> extends Object implements SerializationSchema<T>
SerializationSchema that serializes an object to a JSON String.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.flink.api.common.serialization.SerializationSchema
SerializationSchema.InitializationContext
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper
mapper
-
Constructor Summary
Constructors Constructor Description JsonSerializationSchema()
JsonSerializationSchema(SerializableSupplier<org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper> mapperFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
open(SerializationSchema.InitializationContext context)
Initialization method for the schema.byte[]
serialize(T element)
Serializes the incoming element to a specified type.
-
-
-
Constructor Detail
-
JsonSerializationSchema
public JsonSerializationSchema()
-
JsonSerializationSchema
public JsonSerializationSchema(SerializableSupplier<org.apache.flink.shaded.jackson2.com.fasterxml.jackson.databind.ObjectMapper> mapperFactory)
-
-
Method Detail
-
open
public void open(SerializationSchema.InitializationContext context)
Description copied from interface:SerializationSchema
Initialization method for the schema. It is called before the actual working methodsSerializationSchema.serialize(Object)
and thus suitable for one time setup work.The provided
SerializationSchema.InitializationContext
can be used to access additional features such as e.g. registering user metrics.- Specified by:
open
in interfaceSerializationSchema<T>
- Parameters:
context
- Contextual information that can be used during initialization.
-
serialize
public byte[] serialize(T element)
Description copied from interface:SerializationSchema
Serializes the incoming element to a specified type.- Specified by:
serialize
in interfaceSerializationSchema<T>
- Parameters:
element
- The incoming element to be serialized- Returns:
- The serialized element.
-
-