流文件内容是
{ "resourceType": "患者", "myArray": [1, 2, 3, 4] }
我使用 EvaluateJsonPath 处理器将“myArray”加载到属性 myArray。
然后我使用处理器 AttributesToJSON 从 myArray 创建一个 json。
但在流文件内容中,我得到的是
{"myArray":"[1,2,3,4]"}
我希望流文件具有以下内容。
{"myArray":[1,2,3,4]}
使用面向记录的处理器,如Convert Record 处理器,而不是使用 EvaluateJsonPath,AttributesToJSON 处理器。
RecordReader 作为 JsonPathReader
AvroSchemaRegistry:
{
"namespace": "nifi",
"name": "person",
"type": "record",
"fields": [
{ "name": "myArray", "type": {
"type": "array",
"items": "int"
}}
]
}
Run Code Online (Sandbox Code Playgroud)
JsonSetWriter: 使用相同的 AvroSchemaRegistry 控制器服务来访问架构。要访问AvroSchema,您需要为流文件设置schema.name属性。
输出流文件内容将是
[{"myArray":[1,2,3,4]}]
Run Code Online (Sandbox Code Playgroud)
请参阅此链接如何配置 ConvertRecord 处理器
(或者)
如果没有您应得的输出{"myArray":[1,2,3,4]}
,[](array)
则使用
ReplaceText处理器而不是AttributesToJson处理器。