我定义了一个 DataWeave 函数,它接受字符串作为输入,并且也可以处理空输入。但是,当我使用空输入调用它时,遇到语法错误。谁能告诉我为什么?预先感谢
代码
%dw 2.0
output application/json
fun convertToISO(dateString: String): String =
if (dateString == null or !(dateString contains "Date"))
""
else
do {
var milliseconds = (dateString[6 to -3] as Number)
---
milliseconds as DateTime {unit: "milliseconds"} as String
}
---
{
testCorrect: convertToISO("/Date(1716249600000)/"),
testWrongEmpty : convertToISO(""),
testWrongNull : convertToISO(null)
}