nifi 处理器的 JOLT 规范
JOLT spec for nifi processor
我有以下 JSON 输入
{
"events": [
{
"cluster_id": "0717-035521-puny598",
"timestamp": 1535540053785,
"type": "TERMINATING",
"details": {
"reason": {
"code": "INACTIVITY",
"parameters": {
"inactivity_duration_min": "15"
}
}
}
},
{
"cluster_id": "0717-035521-puny598",
"timestamp": 1535537117300,
"type": "EXPANDED_DISK",
"details": {
"previous_disk_size": 29454626816,
"disk_size": 136828809216,
"free_space": 17151311872,
"instance_id": "6cea5c332af94d7f85aff23e5d8cea37"
}
}
]
}
我想转换成下面的
1) 在"events" 数组的每个对象中添加一个static key:value。
2) 从"events" 数组的每个对象中删除一个元素"type"。
3) 其余 i/p 和 o/p 中的所有值都应该相同。 "details" 是一个没有特定结构的对象。
{
"events": [
{
"new_key" : "new_value",
"cluster_id": "0717-035521-puny598",
"timestamp": 1535540053785,
"details": {
"reason": {
"code": "INACTIVITY",
"parameters": {
"inactivity_duration_min": "15"
}
}
}
},
{
"new_key" : "new_value",
"cluster_id": "0717-035521-puny598",
"timestamp": 1535537117300,
"details": {
"previous_disk_size": 29454626816,
"disk_size": 136828809216,
"free_space": 17151311872,
"instance_id": "6cea5c332af94d7f85aff23e5d8cea37"
}
}
]
}
以下链规范应该有效:
[
{
"operation": "default",
"spec": {
"events[]": {
"*": {
"new-key": "new-value"
}
}
}
},
{
"operation": "remove",
"spec": {
"events": {
"*": {
"type": ""
}
}
}
}
]
我有以下 JSON 输入
{
"events": [
{
"cluster_id": "0717-035521-puny598",
"timestamp": 1535540053785,
"type": "TERMINATING",
"details": {
"reason": {
"code": "INACTIVITY",
"parameters": {
"inactivity_duration_min": "15"
}
}
}
},
{
"cluster_id": "0717-035521-puny598",
"timestamp": 1535537117300,
"type": "EXPANDED_DISK",
"details": {
"previous_disk_size": 29454626816,
"disk_size": 136828809216,
"free_space": 17151311872,
"instance_id": "6cea5c332af94d7f85aff23e5d8cea37"
}
}
]
}
我想转换成下面的
1) 在"events" 数组的每个对象中添加一个static key:value。 2) 从"events" 数组的每个对象中删除一个元素"type"。 3) 其余 i/p 和 o/p 中的所有值都应该相同。 "details" 是一个没有特定结构的对象。
{
"events": [
{
"new_key" : "new_value",
"cluster_id": "0717-035521-puny598",
"timestamp": 1535540053785,
"details": {
"reason": {
"code": "INACTIVITY",
"parameters": {
"inactivity_duration_min": "15"
}
}
}
},
{
"new_key" : "new_value",
"cluster_id": "0717-035521-puny598",
"timestamp": 1535537117300,
"details": {
"previous_disk_size": 29454626816,
"disk_size": 136828809216,
"free_space": 17151311872,
"instance_id": "6cea5c332af94d7f85aff23e5d8cea37"
}
}
]
}
以下链规范应该有效:
[
{
"operation": "default",
"spec": {
"events[]": {
"*": {
"new-key": "new-value"
}
}
}
},
{
"operation": "remove",
"spec": {
"events": {
"*": {
"type": ""
}
}
}
}
]