Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要在 dataweave 中将“\”添加到我的字符串中,但它没有得到 \ 字符
%dw 2.0 output application/json --- { "pdEndDate": "\/Date(" ++ vars.date.startDate ++ ")\/" }
实际的:
{ "pdEndDate": " /Date(1562895466000)N/" }
预期的
{ "pdEndDate": "\/Date(1562895466000)\/" }
你需要\用另一个来逃避\。
\
%dw 2.0 output application/json --- { "pdEndDate": "\\/Date(" ++ vars.date.startDate ++ ")\\/" }
但是您在 JSON 中的输出将如下(带有\\)。
\\
{ "pdEndDate": "\\/Date(1562895466000)\\/" }
由于在 JSON\中是字符串的转义字符,因此您不能只有一个,您需要对其进行转义以将其包含在字符串中。