将字符串转换为整数或数字
如何将字符串转换为Trans ForDataWeave内部的数字/整数。我尝试了以下操作
%dw 2.0
import * from dw::util::Coercions
output application/json
---
{
"quoteId" : vars.setQuoteOppRecIds.Id,
"productCode" : payload.ServiceTypeCode,
"axSequenceNumber" : vars.counter as :number,
"phaseLevel" : payload.PhaseLevel as :number,
"activeInSOW" : if(payload.PhaseLevelActivateInSOW == "Yes") (toBoolean("true")) else (toBoolean("false")),
"phaseLevelProject" : payload.PhaseLevelProject
}
,但我会收到错误,例如无效输入':',预期
} 或',``对于对象表达式''。 (第8行,第41列):
我试图使用Toboolean函数和ITSEEMS来串起布尔值,以工作正常。任何人都可以告诉我什么是我缺少字符串到整数/数字转换的内容
How can I convert the string in to the number/integer inside the transfor dataweave. I tried the below
%dw 2.0
import * from dw::util::Coercions
output application/json
---
{
"quoteId" : vars.setQuoteOppRecIds.Id,
"productCode" : payload.ServiceTypeCode,
"axSequenceNumber" : vars.counter as :number,
"phaseLevel" : payload.PhaseLevel as :number,
"activeInSOW" : if(payload.PhaseLevelActivateInSOW == "Yes") (toBoolean("true")) else (toBoolean("false")),
"phaseLevelProject" : payload.PhaseLevelProject
}
But I get the error like Invalid input ':', expected
}or ',' for the object expression. (line 8, column 41):
I tried to string to boolean using the toBoolean function and itseems to be working fine. Can anyone please tell me what is that I am missing with the string to integer/number conversion
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
DW 2 中的转换语法有所不同。您使用的代码来自 dw 1。在下面的 dw 2 中添加对类型转换的引用,并修复了您的 DW 脚本。
The syntax for conversion in DW 2 is different. The Code you used is from dw 1. Adding references to type conversions in dw 2 below and fixed your DW script as well.