我正在从REST响应中获取JSON正文,其转义字符如下所示。如何使用Groovy脚本在soapUI中格式化JSON响应?
发件人:
{
"employee": "{\"name\":\"John\", \"age\":30, \"city\":\"New York\"}"
}
收件人:
{ "employee": {
"name": "John",
"age": 30,
"city": "New York" } }
答案 0 :(得分:0)
简单的字符串替换即可完成工作:
def escapedString = '''{"employee":"{\"name\":\"John\", \"age\":30, \"city\":\"New York\"}"}'''
def unescapedString = escapedString.replaceAll("\\\\", "")
System.out.println unescapedString
这将产生:
{"employee":"{"name":"John", "age":30, "city":"New York"}"}