2017-08-30 61 views
2

全部。这是我得到了一个GET请求后回响应:Jmeter JSON提取器在响应体内获得令牌值

{"id":30, 
"name":"ABC, Inc.", 
"clientRiskAssessment":{"clientId":30, 
         "generalScore":70, 
         "federalScore":45, 
         "internationalScore":20, 
         "updatedDate":"0001-01-01T00:00:00+00:00", 
         "url":"https://example.com/WebPortal/Config/Tax/index.html?IsFrame=true#/app/questionnaire-response/GeneralTaxClientQa/abd8d723-dc4a-e711-811b-00505683008b", 
         "formattedDate":"01/01/0001"}} 

我可以用$获得“网址”的全价值.. URL中提取JSON - 在JMeter的JSON路径表达式。任何人都可以请给我一个关于如何获得只在url结尾的令牌,而不是整个url值的提示吗?这是我想在URL末尾提取的令牌:abd8d723-dc4a-e711-811b-00505683008b谢谢。

+1

也许,你可以使用[的BeanShell PostProcessor中(https://blazemeter.com/blog/queen-jmeters-built-componentshow-use-beanshell)。参见[这个答案](https://stackoverflow.com/a/32423857/3832970)(3点),你将需要'.replaceFirst( “* /”, “”)' –

+0

感谢@WiktorStribiżewreplaceFirst方法只替换第一个字符。我可以在将它更改为replaceAll –

+0

后获得令牌呃,您不需要'.replaceAll',因为只需要一次匹配。无论如何,两者都会起作用。 –

回答

0

这是如何做到这一点有在我看来,最稳定的提取:

添加到您的HTTP请求:

像这个:

enter image description here

凡JSON提取是这样的:

enter image description here

而且正则表达式提取是:

enter image description here

0

您可以使用RegexPostProcessor与以下配置:

正则表达式:URL * \ /“

模板(*?):$ 1 $

分类号码:1

这将始终捕获从url结尾的令牌。