我收到来自Kafka-connect生产商的以下格式的kafka消息,希望将其反序列化以获取核心数据。
Kafka-connect生产者将其作为“ 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"
}]
}]}}