簡體   English   中英

顛簸轉換,用於從嵌套列表中提取數據

[英]Jolt transformation for extracting data from nested list

從嵌套列表中提取數據的Jolt Spec是什么

我一直在嘗試apache nifi,我想使用joltransformation處理器來解析json流文件內容,但是我無法解析嵌套列表

輸入JSON-

{
"posts": [
 {
   "network": "test",
   "photos": [
     {
       "a": 1.7722222222222221,
       "s": "https://a.com",
       "m": "https://b.com",
       "l": "https://ccccc.com"
     }
   ]
 },
 {
   "network": "test1",
   "photos": [
     {
       "a": 1.7722222222222221,
       "s": "https://d.com",
       "m": "https://e.com",
       "l": "https://fffff.com"
     }
   ]
 }
]
}

JOLT轉換文件-

[
{
 "operation": "shift",
 "spec": {
   "posts": {
     "*": {
       "network": "[&1].profile",
       "photos": { "0": { "l": "[&1].p" } }
     }
   }
 }
}
]

預期產出-

[ 
 {
 "profile" : "test",
 "p" : "https://ccccc.com"
 }, 
 {
 "profile" : "test1",
 "p" : "https://fffff.com"
 }
]

實際輸出-

[ 
 {
 "profile" : "test",
 "p" : [ "https://ccccc.com", "https://ffffff.com" ]
 }, 
 {
 "profile" : "test1"
 }
]

請幫助我,我無法弄清楚我在做什么錯

你很親密

[
  {
    "operation": "shift",
    "spec": {
      "posts": {
        "*": {
          "network": "[&1].profile",
          "photos": { 
            "0": { 
              "l": "[&3].p" 
             } 
           }
        }
      }
    }
  }
]

[&3].p是重要的部分,因為這意味着從3個級別開始使用索引,這是從帖子開始的級別。

暫無
暫無

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

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