gpt4 book ai didi

json - 尼菲 : Extract Content of FlowFile and Add that Content to the Attributes

转载 作者:行者123 更新时间:2023-12-02 03:27:00 24 4
gpt4 key购买 nike

我正在从以下 JSON/AVRO 架构生成随机数据:

{
"type" : "record",
"namespace" : "test",
"name" : "metro_data",
"fields": [
{
"name" : "PersonID",
"type" : "int"
},
{
"name" : "TripStartStation",
"type" : {
"type" : "enum",
"name" : "StartStation",
"symbols" : ["WIEHLE_RESTON_EAST", "SPRING_HILL", "GREENSBORO"]

}
},
{
"name" : "TripEndStation",
"type" : {
"type" : "enum",
"name" : "EndStation",
"symbols" : ["WIEHLE_RESTON_EAST", "SPRING_HILL", "GREENSBORO""]

}
}
]
}

上述架构生成此内容,例如:

[ {
"PersonID" : -1089196095,
"TripStartStation" : "WIEHLE_RESTON_EAST",
"TripEndStation" : "SPRING_HILL"
}

我想获取架构的 PersonID 编号,并将其添加到属性中。例如这张照片中的空白需要拉取流程中生成的实际PersonID号:

enter image description here

我尝试使用具有以下配置的 EvaluateJSONPath,这就是我最终在 PersonalID 下得到 空字符串集 的原因>:

enter image description here

我的下一个处理器是UpdateAttribute吗?不知道如何提取该内容。谢谢!

最佳答案

您有 json 消息数组(例如:[...]),并且您需要使用 将 json 数组拆分为单独的流文件拆分表达式为 $.*

的 Strong>SplitJson 处理器

然后使用 EvaluateJsonProcessor 提取 PersonID 值作为属性。

流程:

--> SplitJson --> EvaluateJsonPath--> other processors

更多详情请参阅this链接涉及同一问题。

关于json - 尼菲 : Extract Content of FlowFile and Add that Content to the Attributes,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53054398/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com