Mule collection splitter with JSON Mule collection splitter with JSON json json

Mule collection splitter with JSON


To do this:

  1. Transform the JSON entity to a hierarchy of Java structures
  2. Extract the record list
  3. Split the list

Now in Mule XML config:

<json:json-to-object-transformer returnClass="java.util.Map" /><expression-transformer expression="#[payload.locations.record]" /><collection-splitter /><!-- TODO: dispatch to queue -->


try this, instead of Map put List. That is working fine for me.

<json:json-to-object-transformer returnClass="java.util.List" /><expression-transformer expression="#[message.payload.locations.record]" /><collection-splitter />


I am adding one more solution in which returnClass="java.util.Map" works please have a look at code in which you can put the same JSON in the body using http method as POST while sending data from Fiddler or POST man client.

Here in this flow i am directly assigning expression in the Splitter instead of using Expression Transformer. I am using Any Point Studio to make it work.

    <flow name="mule-splitterFlow2" doc:name="mule-splitterFlow2">        <http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" doc:name="HTTP" path="splitterjson"/>        <json:json-to-object-transformer returnClass="java.util.Map" doc:name="JSON to Object"/>        <splitter expression="#[message.payload.locations.record]" doc:name="Splitter">        </splitter>        <logger level="INFO" doc:name="Logger" message="#[message.payload]"/>    </flow>