【问题标题】:NIFI: Unable to extract values from JSONNIFI:无法从 JSON 中提取值
【发布时间】:2016-11-24 16:10:33
【问题描述】:

最初我正在查询一个表以获取两个值 id,payload。有效负载字段也是一个 json,但在一个字符串中。请检查下面的有效负载字符串。

{
  "schema": "http://schemas.viacom.com/what/is/the/path#",
  "op": "delete",
  "entity": "movie",
  "entity_identifier": {
    "series_code": 53709,
    "episode_code": 1
  },
  "entity_vmid": "",
  "short_name": "",
  "title": ""
}

我想要 series_code 和 episode_code 值。我尝试了以下方法但没有用

  1. ExecuteSQL --> ConvertAvrotoJSON --> EvaluateJSON($.payload.entity_identifier.series_code)
  2. ExecuteSQL --> ConvertAvrotoJSON --> AttributestoJSON --> EvaluateJSON

请帮忙。

【问题讨论】:

    标签: apache-nifi


    【解决方案1】:

    您可以使用EvaluateJsonPath 处理器根据流文件的内容评估JsonPath 表达式。您为每个要提取的值添加一个用户定义的属性。将Destination 值设置为flowfile-attribute 以将值提取到将添加到流文件中的属性中,或者将flowfile-content 设置为以提取的值作为唯一内容的新流文件。

    鉴于您提供的 JSON,您将使用的两个路径表达式是:

    • $.entity_identifier.series_code -> 53709
    • $.entity_identifier.episode_code -> 1

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-03-07
      • 2017-10-22
      • 2017-06-08
      • 2017-07-30
      • 2023-01-30
      • 1970-01-01
      • 2021-12-16
      • 2017-08-08
      相关资源
      最近更新 更多