java.lang.Object
io.cloudevents.jackson.JsonFormat
- All Implemented Interfaces:
io.cloudevents.core.format.EventFormat
Implementation of
EventFormat for JSON event format
using Jackson. This format is resolvable with EventFormatProvider using the content type CONTENT_TYPE.
If you want to use the CloudEvent serializers/deserializers directly in your mapper, you can use getCloudEventJacksonModule() or
getCloudEventJacksonModule(boolean, boolean) to get a SimpleModule to register in your ObjectMapper instance.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringContent type associated with the JSON event format -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new instance of this class with default serialization configurationJsonFormat(boolean forceDataBase64Serialization, boolean forceStringSerialization) Create a new instance of this class customizing the serialization configuration.JsonFormat(JsonFormatOptions options) Create a new instance of this class customizing the serialization configuration. -
Method Summary
Modifier and TypeMethodDescriptionio.cloudevents.CloudEventdeserialize(byte[] bytes) io.cloudevents.CloudEventdeserialize(byte[] bytes, io.cloudevents.rw.CloudEventDataMapper<? extends io.cloudevents.CloudEventData> mapper) static SimpleModulestatic SimpleModulegetCloudEventJacksonModule(boolean forceDataBase64Serialization, boolean forceStringSerialization) static SimpleModulebyte[]serialize(io.cloudevents.CloudEvent event) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.cloudevents.core.format.EventFormat
deserializableContentTypes
-
Field Details
-
CONTENT_TYPE
Content type associated with the JSON event format- See Also:
-
-
Constructor Details
-
JsonFormat
public JsonFormat(boolean forceDataBase64Serialization, boolean forceStringSerialization) Create a new instance of this class customizing the serialization configuration.- Parameters:
forceDataBase64Serialization- force json base64 encoding for dataforceStringSerialization- force string serialization for non json data field- See Also:
-
JsonFormat
Create a new instance of this class customizing the serialization configuration.- Parameters:
options- json serialization / deserialization options
-
JsonFormat
public JsonFormat()Create a new instance of this class with default serialization configuration
-
-
Method Details
-
withForceJsonDataToBase64
- Returns:
- a copy of this JsonFormat that serialize events with json data with Base64 encoding
-
withForceNonJsonDataToString
- Returns:
- a copy of this JsonFormat that serialize events with non-json data as string
-
withForceExtensionNameLowerCaseDeserialization
- Returns:
- a copy of this JsonFormat that deserialize events with converting extension name lower case.
-
withForceIgnoreInvalidExtensionNameDeserialization
- Returns:
- a copy of this JsonFormat that deserialize events with ignoring invalid extension name
-
serialize
public byte[] serialize(io.cloudevents.CloudEvent event) throws io.cloudevents.core.format.EventSerializationException - Specified by:
serializein interfaceio.cloudevents.core.format.EventFormat- Throws:
io.cloudevents.core.format.EventSerializationException
-
deserialize
public io.cloudevents.CloudEvent deserialize(byte[] bytes) throws io.cloudevents.core.format.EventDeserializationException - Specified by:
deserializein interfaceio.cloudevents.core.format.EventFormat- Throws:
io.cloudevents.core.format.EventDeserializationException
-
deserialize
public io.cloudevents.CloudEvent deserialize(byte[] bytes, io.cloudevents.rw.CloudEventDataMapper<? extends io.cloudevents.CloudEventData> mapper) throws io.cloudevents.core.format.EventDeserializationException - Specified by:
deserializein interfaceio.cloudevents.core.format.EventFormat- Throws:
io.cloudevents.core.format.EventDeserializationException
-
serializedContentType
- Specified by:
serializedContentTypein interfaceio.cloudevents.core.format.EventFormat
-
getCloudEventJacksonModule
- Returns:
- a
SimpleModulewithCloudEventserializer/deserializer configured using default values.
-
getCloudEventJacksonModule
public static SimpleModule getCloudEventJacksonModule(boolean forceDataBase64Serialization, boolean forceStringSerialization) - Parameters:
forceDataBase64Serialization- force json base64 encoding for dataforceStringSerialization- force string serialization for non json data field- Returns:
- a JacksonModule with CloudEvent serializer/deserializer customizing the data serialization.
- See Also:
-
getCloudEventJacksonModule
- Parameters:
options- json serialization / deserialization options- Returns:
- a JacksonModule with CloudEvent serializer/deserializer customizing the data serialization.
-