改进基于char位置格式字符串的脚本
我有一个数字数组,例如:
["5119229", "757218"]
并且我必须在第二个位置后用点输出它们:
["51.19229", "75.7218"]
我通过此脚本实现了它:
payload map ($[0 to 1] ++ "." ++ $[2 to -1])
是否有更好的方法使用 dataweave 2 (及其库?)
I have an array of numbers like:
["5119229", "757218"]
and I must output them with a dot after the second position:
["51.19229", "75.7218"]
I achieved it by this script:
payload map ($[0 to 1] ++ "." ++ $[2 to -1])
is there a better way to do this using dataweave 2 (and its libraries?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您有一系列字符串,而不是数字。
这更干净,尽管效率不高。还有其他问题,例如:字符串总是相同的长度吗?如果一个人太短,我们该怎么办? ETC。
You have an array of strings, not numbers.
This is cleaner though not more efficient; there are other questions like: are the string always the same length? If one is too short, what should we do? Etc.
可能不会。 DataWeave 目前不支持定点数,并且您的数字不是固定长度。
Probably not. There is no currently support for fixed point numbers in DataWeave and your numbers are not fixed length.