我有来自 Kafka-connect producer 的 kafka 消息,格式如下,并希望反序列化它以获取核心数据。
Kafka-connect producer 将它作为“SourceRecord”发送,它嵌入“schema”和“Struct”
如何在 JAVA 或 SCALA 中将数据反序列化并从中提取为域对象?
{"schema": {
"type": "struct",
"fields": [{
"type": "string",
"optional": false,
"field": "dataSourceName"
}, {
"type": "array",
"items": {
"type": "struct",
"fields": [{
"type": "string",
"optional": false,
"field": "dataEntityName"
}, {
"type": "array",
"items": {
"type": "struct",
"fields": [{
"type": "string",
"optional": false,
"field": "name"
...
}, {
"type": "string",
"optional": false,
"field": "part"
}],
"optional": false,
"name": "AvroTestEvent"
},
"payload": {
"dataSourceName": "EmployeeDB",
"changes": [{
"dataEntityName": "dbo.employeeTable",
"fields": [{
"name": "Employee_Id",
"type": "int",
"value": "6"
}, {
"name": "Employee_Name",
"type": "varchar",
"value": "test-employee"
}]
}]}}