Payload Factory Mediators for JSON Message
WSO2 ESB/EI PayloadFactory mediator can be used to replace the contents of a message. As an example, if the backend is accepting a different message structure than what you are receiving, you can use PayloadFactory mediator to change the message structure. Other than that, if you want to transform XML payload into JSON or JSON to XML with different message structure you can use this mediator. Recently, I faced an issue while transforming a message into JSON which is originally read from a CSV file(using Smooks Mediator ). This message can have empty values in the content sometimes and such messages look like below: <Users> <User> <FirstName>Chandana</FirstName> <MiddleName/> </Users> </User> I initially wrote a payload factory mediator like below: <payloadFactory media-type="json"> <format> { "UserInfo": { "fName": "$1", "mName": "$2&qu