简体   繁体   中英

Transform JSONArray values in WSO2 EI

I am having some transformation logic during mediation in wso2 EI. i have stuck while "@type":"Lead" into "attributes":{"type":"Lead"} transformation.

Note: i know to use payloadfactory to achieve this( Expected format). received at least 1000 JSONObject under getFields Array.

Input:

{
"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
    }
}

}

Expected:

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

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

Trying using Foreach mediator with Payload Factory mediator to loop through the array. If Payload Factory does not satisfy your requirement, you may have to use a Custom Class mediator to achieve your requirement.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM