age*_*ntv 1 dataweave mulesoft
...我正在使用 Anypoint Studio 7.6 并在 DataWeave 2.0 中编写
我找不到在带引号的字符串中包含 $(美元符号)字符的明确方法。
这是我尝试过的:
%dw 2.0
output application/dw
var sign = "\u0024" // unicode dollar sign
type currency = String {format: "$sign ###.00"} // interpolation from previous var
var cost = 100 as currency
---
{
directly: "a dollar sign like this: \$",
asdefined: sign,
indirectly: "This flight, costs $(cost), and is operated by "
++ payload.airline
}
Run Code Online (Sandbox Code Playgroud)
这是我遇到的麻烦:
{
directly: "a dollar sign like this: \$",
asdefined: "\$",
indirectly: "This flight, costs \$ 100.00, and is operated by United"
}
Run Code Online (Sandbox Code Playgroud)
我觉得我错过了一些简单的东西。
嗨,您所看到的没有问题,只是您使用 application/dw 作为输出。在那种格式中,$需要转义这就是为什么你会这样看。如果您更改为application/json它们将消失。
| 归档时间: |
|
| 查看次数: |
409 次 |
| 最近记录: |