首页 > 解决方案 > 如何删除 JSON 的键并将整个内容作为内容返回?

问题描述

我的属性员工具有以下 JSON 值:

{"testQuery": {"$set": {"name":"Harsh"} }}

我想将{"$set": {"name":"Harsh"} }流文件内容而不是属性发送到customizedProcessor,需要执行以下操作,

  1. 从属性employee的JSON值中移除testQuery键,
  2. 将 testQuery 的值转换为 flowFile 内容并返回。

标签: apache-nifi

解决方案


我假设您employee在流文件中有属性值:

{"testQuery": {"$set": {"name":"Harsh"} }}

Flow{"$set": {"name":"Harsh"} }作为流文件内容获取:

1. ReplaceText       - to store attribute into content
   Replacement Value = ${employee}

2. EvaluateJsonPath  - to extract required json value and put into content
   Destination       = flowfile-content
   value             = $.testQuery

推荐阅读