无法使用json路径Tester-Jmeter解析响应

时间:2017-01-03 11:01:32

标签: jmeter

无法解析包含" \",

的响应
{"Content":"[{\"SummaryID\":\"402014189352\",\"PeriodID\":\"3079\",\"PeriodName\":\"Q3 16\",\"SummaryData\":[{\"SummaryID\":\"402014189352\",\"Date\":\"11\/11\/2016\",\"RawMatrixData\":\"{\\\"LstEstimateInfo\\\":[{\\\"TemplateID\\\":402014189251,\\\"SummaryID\\\":402014189352,\\\"TemplateName\\\":\\\"Template_201611119\\\",\\\"TemplateDate\\\":\\\"11\/11\/2016 08:48:09\\\",\\\"SelfServe\\\":true}],\\\"LstPeriodList\\\":[{\\\"PeriodName\\\":\\\"Q1

2 个答案:

答案 0 :(得分:1)

尝试使用Regular Expression ExtractorBeanShell Post Processor

步骤如下:

Regular Expression Extractor中添加以下正则表达式(以检索日期值):

"Date\\":\\"(.*?)"

按如下方式添加BeanShell代码(在第一场比赛中删除" \"):

String str1=vars.get("date_1").toString();
log.info("Before " + str1);
String temp = str1.replace("\\","");
log.info("After " + temp);
vars.put("date_formatted", temp);

图片参考: 1. RegEx Extractor enter image description here 2. BeanShell enter image description here 3.查看结果树 enter image description here

答案 1 :(得分:0)

String str1=vars.get("SummaryID").toString();
String str2=vars.get("TemplateID").toString();
log.info("Before " + str1);
log.info("Before " + str2);
java.lang.String temp = str1.replace("\\","");
java.lang.String temp1 = str2.replace("\\","");
log.info("After " + temp);
log.info("After " + temp1);
vars.put("date_format1", temp);
vars.put("date_format2", temp1);

尝试上面的代码,删除“\”,当我想传递$ {SummaryID_1}时,发布请求无效。