wso2wso2-esbwso2-enterprise-integrator

Can't Loop over JSON Array from JSON Property in WSO2 ESB


I'm trying to loop over static json array list and i store the json object into property and i want to log all values in this array

<inSequence>
    <property name="numbersJSONOBJ" scope="default" type="STRING" value="{&quot;numbers&quot;:[1,2,3]}"/>
    <property expression="json-eval($ctx:numbersJSONOBJ)" name="numbersList" scope="default" type="STRING"/>
    <log level="custom">
        <property expression="get-property('numbersList')" name="numbers"/>
    </log>
    <foreach expression="$ctx:numbersList">
        <sequence>
            <log level="custom">
                <property name="MSG" value="INSIDE FOR EACHE"/>
            </log>
            <log level="full">
                <property expression="json-eval($)" name="number"/>
            </log>
        </sequence>
    </foreach>
    <respond/>
</inSequence>

and the output logs is

[2024-06-28 15:12:42,719]  INFO {APIDeployer} - API named 'NumbersAPI' has been deployed from file : D:\Programs\WSO2\IntegrationStudio\runtime\microesb\tmp\carbonapps\-1234\1719580362569TestCompositeApplication_1.0.0.car\NumbersAPI_1.0.0\NumbersAPI-1.0.0.xml [2024-06-28 15:12:42,719]  INFO {CappDeployer} - Successfully Deployed Carbon Application : SOAP_PostmanAPIs_To_RESTApisCompositeExporter_1.0.0-SNAPSHOT{super-tenant} [2024-06-28 15:12:45,778]  INFO {LogMediator} - {api:NumbersAPI} numbers = {"numbers":[1,2,3]}

i'm expecting the values to be loged in the console but it does not happen


Solution

  • I tried an to use (Enrish Mediator to store a XML) or (Property to store the xml value as a "OM" type) and then use the ForEach Mediator with expression "$ctx:PropertyName//XMLListName and to see if it works fine add a Log Mediator with Full logging to log each message it iterate over it