You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

新手求助:如何在Mule DataWeave中获取HashMap的memberId值?

DataWeave提取HashMap中memberId值的正确方法

你的代码编译错误是因为pluck与filter的调用顺序不符合DataWeave语法规范。正确逻辑是先通过pluck将HashMap转换为包含所有子对象的数组,再对数组进行过滤操作。

正确写法1(filter+索引取值)

(payload pluck $) filter ($.key == "memebrId")[0].value

正确写法2(find函数更简洁)

((payload pluck $) find ($.key == "memebrId")).value

说明

  • payload pluck $:将原HashMap的所有子对象(即每个包含key和value的结构)提取为一个数组
  • filter/find:筛选出key等于"memebrId"的对象(注意原数据中key拼写为memebrId,若实际应为memberId需同步修正)
  • 最后通过.value获取目标值

内容的提问来源于stack exchange,提问作者Krish

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.23 05:54:38