NiFi 1.23.2.a中Jolt Transform实现JSON数组层级提升问题
NiFi 1.23.2.a 中JSON数组层级提升的Jolt解决方案
问题背景
当前使用NiFi 1.23.2.a版本,需要将输入JSON中的数组层级提升一级:
- 输入JSON(注:原输入存在语法错误,修正为标准数组包裹对象格式):
[ { "count": 50, "ins": { "in": [ {"type": "value1", "required": "true"}, {"type": "value2", "required": "true"} ] } } ]
- 期望输出JSON:
{ "count": 50, "in": [ {"type": "value1", "required": "true"}, {"type": "value2", "required": "true"} ] }
原NiFi 1.19版本可用的Jolt配置在升级后失效。
修正后的Jolt Transform配置
使用以下Shift操作配置即可实现需求:
[ { "operation": "shift", "spec": { "*": { "count": "count", "ins": { "in": "in" } } } } ]
配置说明
- 外层
"*"匹配输入数组中的唯一对象元素; "count": "count"直接将原对象中的count字段映射到顶层;"ins": {"in": "in"}跳过ins中间层级,直接将其下的in数组映射到顶层的in字段。
内容的提问来源于stack exchange,提问作者Ginger
相关产品推荐
相关产品推荐

