When i was trying to construct an JSON payload by Iterating the JSON array by using Iterator and extracting the specific field from the payload and trying to form an Json Payload by using Payload factory inside an Iterator after Iterator i was trying to set an aggregate mediator to aggregate all the json response and trying to set into the context for transformation and responding back to the Client
Sequence for generation of Desired Output by using Iterator with Aggregate mediator
`<?xml version="1.0" encoding="UTF-8"?>
<sequence name="AGGREGATE_CHECK" trace="disable" xmlns="http://ws.apache.org/ns/synapse">
<iterate continueParent="true" expression="//Customers" id="line-Item-Iterator" sequential="true">
<target>
<sequence>
<property expression="//Name" name="Name" scope="default" type="STRING"/>
<property expression="//DOJ" name="Doj" scope="default" type="STRING"/>
<payloadFactory media-type="json">
<format>{
"NAME": "$1",
"DOJ": $2,
}</format>
<args>
<arg evaluator="xml" expression="$ctx:Name"/>
<arg evaluator="xml" expression="$ctx:Doj"/>
</args>
</payloadFactory>
<log level="full"/>
</sequence>
</target>
</iterate>
<log>
<property name="after iterator" value="coming out for aggregator"/>
</log>
<aggregate id="line-Item-Iterator">
<completeCondition>
<messageCount max="-1" min="-1"/>
</completeCondition>
<onComplete aggregateElementType="root" expression="json-eval($)">
<property expression="$body/*" name="response" scope="operation" type="OM"/>
<log level="full"/>
</onComplete>
</aggregate>
<payloadFactory media-type="json">
<format>$1</format>
<args>
<arg evaluator="xml" expression="get-property('operation','response')"/>
</args>
</payloadFactory>
<log>
<property expression="$body/*" name="Aggregated-response"/>
</log>
</sequence>
`
Note:
- If I try to log the response inside the iterator logging is happening with the proper output payload
- Tried by changing the continueParent in iterate mediator to false as well no proper output
- If I tried logging inside the onComplete block we are not getting any logs inside the Aggregate mediator
Needed help to understand this issue and solve it
Thanks in Advance
INPUT PAYLOAD
`{
"data": {
"level": "asss",
"Info": {
"Customers": [
[
{
"Name": "Ram",
"Age": 26,
"city": "TX",
"DOJ": "26-06-2002"
},
{
"Name": "Shri",
"Age": 29,
"city": "TX",
"DOJ": "12-06-1999"
},
{
"Name": "Reena",
"Age": 25,
"city": "TX",
"DOJ": "22-06-2007"
}
]
]
}
},
"ms": {}
}`
excepted output
[
{
"Name": "Ram",
"DOJ": "26-06-2002"
},
{
"Name": "Shri",
"DOJ": "12-06-1999"
},
{
"Name": "Reena",
"DOJ": "22-06-2007"
}
]