NIFI:无法从JSON提取值

问题描述:

最初我正在查询表以获取两个值id,有效负载。有效载荷字段也是一个json,但是是一个字符串。请检查下面的负载字符串。NIFI:无法从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

请帮忙。

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

给你提供的JSON,你会使用这两种路径表达式是:

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