json - 选择过滤器中的 Mule JSON Payload null 检查
问题描述
我在这里做错什么了吗?即使 json 有效负载是 [],它也会使用默认值而不是错误日志。
<choice doc:name="If Payload is Null">
<when expression="#[payload == empty]">
<mule-logger-module:logger-exception message="Null Payload" doc:name="Log Error"/>
</when>
<otherwise>
<mule-logger-module:log-default message="Payload Received" type="EXIT" doc:name="Log End"/>
</otherwise>
</choice>
解决方案
首先转换为 Maps 数组,然后使用 MEL 表达式测试为空:
<json:json-to-object-transformer
returnClass="java.util.HashMap[]" doc:name="JSON to Object" />
<choice doc:name="If Payload is Null">
<when expression="#[payload == empty]">
<mule-logger-module:logger-exception message="Null Payload" doc:name="Log Error"/>
</when>
<otherwise>
<mule-logger-module:log-default message="Payload Received" type="EXIT" doc:name="Log End"/>
</otherwise>
推荐阅读
- mule - Mule3 中阿拉伯语语言环境的日期格式错误
- python - 使用python进行曲线拟合
- google-chrome-extension - 如何使 chrome 扩展在 iframe 内部和 iframe 外部工作?
- javascript - 如何在 python 中获取 Javascript var 抓取和使用 Webdriver?
- reactjs - Redux/Redux-Saga 中的回调是反模式?
- ios - Xcode 13. 使用 SPM(Swift 包管理器)时参数列表太长
- sql - UPDATE 语句后出现双“x 行受影响”消息?
- android - Android 将特定 API 调用限制为 3 秒内一次
- fastify - 我如何在 Fastify 中配置从 fastifify cli 创建的记录器文件
- html - 是否有任何技巧可以在纯 HTML/CSS 中设置滚动条位置?