on 08-10-2022 7:54 PM
Dear All,
I'm converting payload XML to JSON using a standard converter.
The field "rows" is an array which should be generated like this "rows": [] when there are no values.
But the output from converter is "rows": [" "]Best Regards
Revathi
Hello,
You need to escape both the square brackets [] and double quotes " when using replaceAll since they are treated
as a regex statement. Both statements below should work
String sample = """"rows":[" "],\n"rows1":[" "]\n"""
println("Replace: "+sample.replace('[" "]','[]'))
println("ReplaceAll: "+sample.replaceAll('\\[\" \"\\]','[]'))
Hope this helps,
Mark
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
68 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.