现象:
{"message":"JSON parse error: Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value\n at [Source: (PushbackInputStream); line: 5, column: 279]
原因:
获取的字段里存在换行符,导致传递给下一个post请求的时候换行符导致json解析错误,需要进行转义
解决方法:使用beashell处理下字符串
caseTitle是从上一个json提取器里获取的
var caseTitle_var=vars.get("caseTitle");//获取需要处理的字符串log.info(caseTitle_var); //打印var caseTitle_var_after=caseTitle_var.replace("\n","\\n"); //将“\/”替换为"/",替换前面添加一个“\”进行转义,否则会报错log.info(caseTitle_var_after);vars.put("caseTitle",caseTitle_var_after); //