简体   繁体   English

在 WSO2 EI 中转换 JSONArray 值

[英]Transform JSONArray values in WSO2 EI

I am having some transformation logic during mediation in wso2 EI.我在 wso2 EI 的调解期间有一些转换逻辑 i have stuck while "@type":"Lead" into "attributes":{"type":"Lead"} transformation.我在"@type":"Lead" 转换为 "attributes":{"type":"Lead"}转换时卡住了。

Note: i know to use payloadfactory to achieve this( Expected format).注意:我知道使用 payloadfactory 来实现这一点(预期格式)。 received at least 1000 JSONObject under getFields Array.在 getFields 数组下收到至少 1000 个 JSONObject。

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.尝试使用 Foreach 调解器和 Payload Factory 调解器来循环遍历数组。 If Payload Factory does not satisfy your requirement, you may have to use a Custom Class mediator to achieve your requirement.如果 Payload Factory 不能满足您的要求,您可能必须使用自定义类中介来实现您的要求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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