簡體   English   中英

需要有關從Apache NiFi中的流文件中檢索JSON屬性的幫助

[英]Need help on retrieving JSON attributes from a flow file in Apache NiFi

我正在嘗試使用NiFi中的EvaluvateJsonPath處理器從JSON文件中獲取屬性值。

下面是示例JSON文件

{"widget": {
    "debug": "on",
    "window": {
        "title": "Sample Konfabulator Widget",
        "name": "main_window",
        "width": 500,
        "height": 500
    },
    "image": { 
        "src": "Images/Sun.png",
        "name": "sun1",
        "hOffset": 250,
        "vOffset": 250,
        "alignment": "center"
    },
    "text": {
        "data": "Click Here",
        "size": 36,
        "style": "bold",
        "name": "text1",
        "hOffset": 250,
        "vOffset": 100,
        "alignment": "center",
        "onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"
    }
}}

以下是我的配置。

組態

預期的輸出應為“main_window”。 但我將整個JSON字符串作為輸出。 有人可以指出我正確的方向,這里出了什么問題?

更新:

這是流文件內容,我在隊列中看到的是EvaluvateJsonPath處理器的結果。

在此輸入圖像描述

你正確地給了"Name"-->$.widget.window.name

但是你必須指定"ReturnType"-->json不是"ReturnType"-->autodetect

這是你收到整個json字符串的問題。

編輯-1

如果將返回類型更改為json,則可以接收預期輸出“main_window”以存儲在Attribute $ {Name}中

之后,您可以使用ReplaceText處理器指定替換值“$ {Name}”,然后您可以在flowfile中收到“main_window”

它可以為我工作。

如果您遇到任何問題,請告訴我

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM