2017-08-30 90 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結尾的令牌。