irr*_*ser 4 json jolt apache-nifi
我正在使用带有分隔符的 Flatten Json 处理器_,到目前为止,它可以很好地展平嵌套记录。但我也注意到它会干扰已经有“_”的键。例如:
{
"first_name": "myfirstname",
"last_name": "mylastname",
"address": {
"billing": "mybilling",
"shipping": "myshipping"
}
}
Run Code Online (Sandbox Code Playgroud)
展平为:
{
"[\"first_name\"]": "myfirstname",
"[\"last_name\"]": "mylastname",
"address_billing": "mybilling",
"address_shipping": "myshipping"
}
Run Code Online (Sandbox Code Playgroud)
同时,“ ”记录按预期被展平,具有字符address的键first_name和也受到干扰。有什么办法可以绕过这个吗?(也许是一种逃避非记录类型的方法?)last_name_
要解决此问题,您可以使用
JoltTransformJson处理器
(或者)
将分隔符(如“|”、“-”..等)保留在FlattenJson中,即
not present in key名称。
1.使用JoltTransformJson处理器:
规格:
[
{
"operation": "shift",
"spec": {
"*": "&",
"address": {
"*": "address_&"
}
}
}
]
Run Code Online (Sandbox Code Playgroud)
输出:
{
"first_name" : "myfirstname",
"last_name" : "mylastname",
"address_billing" : "mybilling",
"address_shipping" : "myshipping"
}
Run Code Online (Sandbox Code Playgroud)
2.FlattenJson处理器:
输出:
{
"first_name": "myfirstname",
"last_name": "mylastname",
"address|billing": "mybilling",
"address|shipping": "myshipping"
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2549 次 |
| 最近记录: |