我有json喜欢
{
"error_message_1": "missing_field_1",
"error_message_2": "missing_field_2",
"error_message_3": "missing_field_3"
}Run Code Online (Sandbox Code Playgroud)
{
"payloads":[
{
"error_message_1": "missing_field_1",
"error_message_2": "missing_field_2"
"error_message_3": "missing_field_3"
}],
"timestamp":"$timestmap",
"source":"nifi"
}
Run Code Online (Sandbox Code Playgroud)
请让我知道这个jolt脚本.
使用这个震动规范:
我们正在创建有效负载 array并将所有error_message*密钥保存到有效负载数组中.
[{
"operation": "shift",
"spec": {
"error_message_1": "payloads[0].error_message_1",
"error_message_2": "payloads[0].error_message_2",
"error_message_3": "payloads[0].error_message_3"
}
}, {
"operation": "default",
"spec": {
"timestamp":"$timestmap",
"source":"nifi"
}
}]
Run Code Online (Sandbox Code Playgroud)
输出:
此外,如果您想要时间戳键的timestamp值,请使用以下规范:
[{
"operation": "shift",
"spec": {
"error_message_1": "payloads[0].error_message_1",
"error_message_2": "payloads[0].error_message_2",
"error_message_3": "payloads[0].error_message_3"
}
}, {
"operation": "default",
"spec": {
"timestamp":"${now():format('yyyy-MM-dd HH:mm:ss.SSS')}",
"source":"nifi"
}
}]
Run Code Online (Sandbox Code Playgroud)
输出:
{
"payloads": [{
"error_message_1": "missing_field_1",
"error_message_2": "missing_field_2",
"error_message_3": "missing_field_3"
}],
"source": "nifi",
"timestamp": "2018-10-30 08:51:16.572"
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
106 次 |
| 最近记录: |