dwel
8 months agoNew Contributor
How do I prevent a file path from being altered when being parsed by JsonSlurper in Groovy Script?
I have a Groovy Script step which parses though a number of JSON objects from a REST response and saves certain parameters to be used in a following REST request. One of these parameters is the file ...
- 7 months ago
I was able to find a solution. I added the following line to my groovy script to reformat the file path before saving it in the test case parameters. Heres the line:
fullFilePath = fullFilePath.replaceAll("\\\\", "\\\\\\\\")
because a '\' is considered a special character I had to represent it differently in the replaceAll method. The string "\\\\" actually represents a single '\' character and so by doubling the number to 8 backslash characters I was able to properly replace the single '\' with the double backslash again.