我正在尝试在输入json下面转换为在保留所有元数据的同时,平整必要的列名称及其值。
下面是我在CDC用例中使用的输入json 。
{
"type": "update",
"timestamp": 1558346256000,
"binlog_filename": "mysql-bin-changelog.000889",
"binlog_position": 635,
"database": "books",
"table_name": "publishers",
"table_id": 111,
"columns": [
{
"id": 1,
"name": "id",
"column_type": 4,
"last_value": 2,
"value": 2
},
{
"id": 2,
"name": "name",
"column_type": 12,
"last_value": "Suresh",
"value": "Suresh123"
},
{
"id": 3,
"name": "email",
"column_type": 12,
"last_value": "Suresh@yahoo.com",
"value": "Suresh@yahoo.com"
}
]
}
下面是预期的输出json
[
{
"type": "update",
"timestamp": 1558346256000,
"binlog_filename": "mysql-bin-changelog.000889",
"binlog_position": 635,
"database": "books",
"table_name": "publishers",
"table_id": 111,
"columns": {
"id": "2",
"name": "Suresh123",
"email": "Suresh@yahoo.com"
}
}
]
我尝试了以下规范,可以从中检索column对象,但无法检索其余元数据。
[
{
"operation": "shift",
"spec": {
"columns": {
"*": {
"@(value)": "[#1].@(1,name)"
}
}
}
}
]
非常感谢任何潜在客户。
答案 0 :(得分:1)
我获得了上述转换的JOLT规范。如果有人偶然发现像这样的东西,我会把它张贴在这里。
[
{
"operation": "shift",
"spec": {
"columns": {
"*": {
"@(value)": "columns.@(1,name)"
}
},
"*": "&"
}
}
]