EvaluateJsonPath

文档中心 › 组件索引 › EvaluateJsonPath

EvaluateJsonPath Processor

类型全限定名:cn.org.acal.lynxus.processors.standard.EvaluateJsonPath

所属 Bundle:cn.org.acal.lynxus:lynxus-standard-nar:2.11.8

描述

对 FlowFile 的内容计算一个或多个 JsonPath 表达式。

标签

JSONevaluateJsonPath

属性

下表中,加粗的属性为必填项;其余为可选项。表格同时标注默认值、是否支持表达式语言,以及是否为敏感属性(值会被加密)。

名称默认值可选值描述
Destinationflowfile-content
  • flowfile-content
  • flowfile-attribute
指示 JsonPath 求值的结果是写入 FlowFile 内容还是 FlowFile 属性;如果使用属性,必须指定属性名称属性。如果设置为 flowfile-content,则只能指定一个 JsonPath,属性名称将被忽略。
Return Typeauto-detect
  • auto-detect
  • json
  • scalar
指示 JSON Path 表达式的期望返回类型。选择 'auto-detect' 将根据目标设置返回类型:'flowfile-content' 目标使用 'json','flowfile-attribute' 目标使用 'scalar'。
Path Not Found Behaviorignore
  • warn
  • ignore
  • skip
指示当目标设置为 'flowfile-attribute' 时如何处理缺失的 JSON Path 表达式。选择 'warn' 将在找不到 JSON Path 表达式时生成警告。选择 'skip' 将省略任何未匹配的 JSON Path 表达式的属性。
Null Value Representationempty string
  • the string 'null'
  • empty string
指示导致空值的 JSON 路径表达式的所需表示形式。
Max String Length20 MB解析JSON文档时字符串值允许的最大长度

动态属性

动态属性允许用户自定义属性的名称与值。

名称值描述
一个 FlowFile 属性(如果 <Destination> 设为 'flowfile-attribute')一个 JsonPath 表达式如果 <Destination>='flowfile-attribute',则该 FlowFile 属性将被设置为匹配 JsonPath 的任何 JSON 对象。如果 <Destination>='flowfile-content',则 FlowFile 内容将被更新为匹配 JsonPath 的任何 JSON 对象。

关系 (Relationships)

名称描述自动终止
failure当无法对 FlowFile 的内容进行 JsonPath 求值时,FlowFile 被路由到此关系;例如,FlowFile 不是有效的 JSON。否
matched当成功评估 JsonPath 并因此修改 FlowFile 时,FlowFiles 将路由到此关系否
unmatched当 JsonPath 与 FlowFile 的内容不匹配并且 Destination 设置为 flowfile-content 时,FlowFiles 将路由到此关系否

状态管理

该组件不存储状态。

受限 (Restricted)

该组件不受限。

输入要求

该组件要求有传入连接。

详细说明

EvaluateJsonPath

注意: 底层 JsonPath 库会将流式内容的整体加载到内存中,并在内存中执行结果求值。因此,务必评估 此 Processor 所处理内容的预期规模以及承载它的硬件能力,在处理大型 JSON 文档时尤其如此。

附加说明

在 Lynxus 中,利用 Attribute 构造 JSON 是一种常见的模式,而许多 Attribute 的名称中包含句点,例如 record.count。要安全地引用这类 Attribute,必须采用将整个键放入方括号中的写法;对于包含空白字符的 JSON 键同样适用:

$.["record.count"]

$.["record count"]