Dataweave - 字符串数组删除方括号
Dataweave - String array remove square brackets
我得到这个字符串数组:
["HELLO","WORLD"]
我想输出相同但没有方括号:
"HELLO","WORLD"
如何在 Mule 中用 Dataweave 替换或转换它?
可能的解决方案(在评论中归功于@jerney)
使用索引操作:
%dw 1.0
%output application/java
%var input = "[\"HELLO\", \"WORLD\"]"
---
input[1..-2]
使用正则表达式:
%dw 1.0
%output application/java
%var input = "[\"HELLO\", \"WORLD\"]"
---
input replace /^\[|\]$/ with ""
使用简单替换:
%dw 1.0
%output application/java
%var input = "[\"HELLO\", \"WORLD\"]"
---
input replace "[" with "" replace "]" with ""
我得到这个字符串数组:
["HELLO","WORLD"]
我想输出相同但没有方括号:
"HELLO","WORLD"
如何在 Mule 中用 Dataweave 替换或转换它?
可能的解决方案(在评论中归功于@jerney)
使用索引操作:
%dw 1.0
%output application/java
%var input = "[\"HELLO\", \"WORLD\"]"
---
input[1..-2]
使用正则表达式:
%dw 1.0
%output application/java
%var input = "[\"HELLO\", \"WORLD\"]"
---
input replace /^\[|\]$/ with ""
使用简单替换:
%dw 1.0
%output application/java
%var input = "[\"HELLO\", \"WORLD\"]"
---
input replace "[" with "" replace "]" with ""