Search code examples
mulemule-el

Expression Component JSON parsing


I have 10 variables I need to set by parsing JSON payload like #[json:REQUEST_ID] etc. Can this be done thru an expression component all of the variables instead of using Set Variable one after the other. I am looking for how to parse a json payload within an expression component. Many Thanks.


Solution

  • You can use <message-properties-transformer> to simplify the handling of variables on the flow, for example:

    <message-properties-transformer doc:name="Message Properties">
        <add-message-property key="variableName" value="#[payload.from]" />         
        <add-message-property key="prmts" value="#[org.apache.commons.lang.StringUtils.split(payload.parameters, ';')]" />                  
    </message-properties-transformer>
    

    I hope I can help you.