浏览 Dataweaver 文档链接:https ://developer.mulesoft.com/docs/dataweave#_attribute_selector_expressions
第 3.4 节 Key Present 试用下面提供的示例。
Input:
<users>
<name>Mariano</name>
<name>Luis</name>
<name>Mariano</name>
</users>
转换:
%dw 1.0
%input payload application/xml
%output application/xml
---
users: payload.users.name[?($ == "Mariano")]
当我尝试在我的 DataWeaver 中给出这个表达式时,它会给出类似cannot coerce a:string to a: array:(7,92)
. 已经给出了文档中提到的相同方式。有人可以请教。
预期反应:
<?xml version="1.0" encoding="UTF-8"?>
<users>
<name>Mariano</name>
<name>Mariano</name>
</users>
同样在文档 1.1.2 字符串操作示例中对我不起作用
%dw 1.0
%input payload application/xml
%output application/json
%function words(name) name splitBy " "
---
contacts: payload.users.*user map using (parts = words($.name)){
firstName: parts[0],
(secondName: parts[1]) when (sizeOf parts) > 2,
lastName: parts[-1],
email: "$((lower $.name) replace " " with ".")@acme.com.ar",
address: $.street
}
显示错误multiple marker at this line missing '}' no viable alternative at input email
开始学习并处理提供的示例。谢谢。