Member-only story
Mulesoft: looping an array of inner objects of a json message with for-each component
Recently I was tasked with converting a json message to an appropriate one line message segment. Here the json message is originated from a newly created separate machine and is sent to an old legacy system which accepts incoming messages only as a single line segment. To support this integration between two systems, “mulesoft integration platform” was placed in between these systems. This moved the responsibility of data preparation according to the destination system to this middle entity (mulesoft esb) other than doing any change to destination systems.
Let’s say our json message is something like below:
And we want it be converted into following structure as the legacy system will be expecting above elements in those shown lengths and in that order. If an element does not have enough data to fill up that length, then the relevant amount of spaces must be padded so that length would fill up. As an example for the itemName, the legacy system expects data in that place up to 15 characters in length. But in both above items, it does not have that much of length in their names. So we have to code in mulesoft…