簡體   English   中英

在 WSO2 EI 中轉換 JSONArray 值

[英]Transform JSONArray values in WSO2 EI

我在 wso2 EI 的調解期間有一些轉換邏輯 我在"@type":"Lead" 轉換為 "attributes":{"type":"Lead"}轉換時卡住了。

注意:我知道使用 payloadfactory 來實現這一點(預期格式)。 在 getFields 數組下收到至少 1000 個 JSONObject。

輸入:

{
"getDataResponse":{
    "result":{
        "DataSyncTime":"sometime",
        "getFields":[
            {
                "@type":"Lead",
                "FirstName":"Justin"
            },
            {
                "@type":"Lead",
                "FirstName":"Manoj"
            }
          //received atleast 1000 records ie jsonobject here(Dynamic)
            ],
            "Message" :"Text messsage",
            "Success":200
    }
}

}

預期的:

{
    "DataSyncTime":"sometime",
    "getEvents":[],
    "getFields":[
            {
                "attributes":{"type":"Lead"},
                "FirstName":"Justin"
            },
            {
                "attributes":{"type":"Lead"},
                "FirstName":"Manoj"
            }

            ],
            "getTask":[],
            "Message" :"Text messsage",
            "Success":200
}

嘗試使用 Foreach 調解器和 Payload Factory 調解器來循環遍歷數組。 如果 Payload Factory 不能滿足您的要求,您可能必須使用自定義類中介來實現您的要求。

暫無
暫無

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

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