表达式组件JSON解析

问题描述 投票:0回答:2

我需要通过解析JSON有效负载来设置10个变量,如#[json:REQUEST_ID]等。这可以通过表达式组件完成所有变量,而不是一个接一个地使用Set Variable。我正在寻找如何解析表达式组件中的json有效负载。非常感谢。

mule mel
2个回答
0
投票

您可以使用<message-properties-transformer>来简化流上变量的处理,例如:

<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>

我希望我能帮助你。


0
投票

我更喜欢enricher到这里的消息属性变换器:

<enricher>
    <enrich target="#[variable:requestId] source="#[json:REQUEST_ID]" />
    <enrich target="#[variable:otherThing] source="#[json:OTHER_THING]" />
</enricher>
© www.soinside.com 2019 - 2024. All rights reserved.