<commit_before>= Debezium Event Deserialization
include::../_attributes.adoc[]
:toc:
:toc-placement: macro
:linkattrs:
:icons: font
:source-highlighter: highlight.js

toc::[]

[NOTE]
====
This feature is currently in incubating state, i.e. exact semantics, configuration options etc. may change in future revisions, based on the feedback we receive. Please let us know if you encounter any problems will using these SerDes.
====

Debezium generates data change events in the form of a complex message structure.
This message is later on serialized by the configured Kafka Connect converter and it is the responsibility of the consumer to deserialize it into a logical message.
For this purpose, Kafka uses the so-called https://kafka.apache.org/documentation/streams/developer-guide/datatypes.html[SerDes].

Debezium provides SerDes (`io.debezium.serde.DebeziumSerdes`) to simplify the deserialization for the consumer either being it Kafka Streams pipeline or plain Kafka consumer.

== JSON SerDe

The JSON SerDe deserializes JSON encoded change events and transforms it into a Java class.
Internally this is achieved using https://github.com/FasterXML/jackson-databind/wiki[Jackson Databind].

The consumer creates a serde instance using

[source,java,indent=0]
----
final Serde<MyType> serde = Serdes.payloadJson(MyType.class);
----

The consumer will then receive the logical Java type `MyType` whose fields are initiated from the JSON message.
This applies to both for keys and values.
It is also possible to use plain Java types like `Integer`, for example when the key consists of a single `INT` field.

When the JSON converter is used by Kafka Connect then it generally provides two modes of operations - with or without schema.
If the schema is used then the message looks like so:

[source,json,indent=0]
----
{
    "schema": {...},
    "payload": {
    	"op": "u",
    	"source": {
    		...
    	},
    	"ts_ms" : "...",
    	"before" : {
    		"field1" : "oldvalue1",
    		"field2" : "oldvalue2"
    	},<commit_msg>Update serdes.adoc<commit_after>= Debezium Event Deserialization
include::../_attributes.adoc[]
:toc:
:toc-placement: macro
:linkattrs:
:icons: font
:source-highlighter: highlight.js

toc::[]

[NOTE]
====
This feature is currently in incubating state, i.e. exact semantics, configuration options etc. may change in future revisions, based on the feedback we receive. Please let us know if you encounter any problems will using these SerDes.
====

Debezium generates data change events in the form of a complex message structure.
This message is later on serialized by the configured Kafka Connect converter and it is the responsibility of the consumer to deserialize it into a logical message.
For this purpose, Kafka uses the so-called https://kafka.apache.org/documentation/streams/developer-guide/datatypes.html[SerDes].

Debezium provides SerDes (`io.debezium.serde.DebeziumSerdes`) to simplify the deserialization for the consumer either being it Kafka Streams pipeline or plain Kafka consumer.

== JSON SerDe

The JSON SerDe deserializes JSON encoded change events and transforms it into a Java class.
Internally this is achieved using https://github.com/FasterXML/jackson-databind/wiki[Jackson Databind].

The consumer creates a serde instance using

[source,java,indent=0]
----
final Serde<MyType> serde = DebeziumSerdes.payloadJson(MyType.class);
----

The consumer will then receive the logical Java type `MyType` whose fields are initiated from the JSON message.
This applies to both for keys and values.
It is also possible to use plain Java types like `Integer`, for example when the key consists of a single `INT` field.

When the JSON converter is used by Kafka Connect then it generally provides two modes of operations - with or without schema.
If the schema is used then the message looks like so:

[source,json,indent=0]
----
{
    "schema": {...},
    "payload": {
    	"op": "u",
    	"source": {
    		...
    	},
    	"ts_ms" : "...",
    	"before" : {
    		"field1" : "oldvalue1",
    		"field2" : "oldvalue2"
    	},
{'fraction_non_alphanumeric': 0.09113239990174404, 'fraction_numerical': 0.0029476787030213707, 'mean_word_length': 4.0333745364647715, 'pattern_counts': {'":': 8, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3016405', 'n_tokens_mistral': 1177, 'n_tokens_neox': 1146, 'n_words': 499}