[英]how to extract json response data in jmeter using regular expression extractor?
I am just trying to extract json response data using jmeter but not able to do so. 我只是尝试使用jmeter提取json响应数据但不能这样做。
I am getting something like {"authorizationToken":"abcdef"}
. 我得到类似{"authorizationToken":"abcdef"}
。
I am trying to get authorizationToken
but not able to get this. 我试图获得authorizationToken
但无法获得此authorizationToken
。
Can anyone help me getting this working? 任何人都可以帮我搞定这个吗?
Is authorizationToken
appearance unique in response (does it appear only once)? authorizationToken
外观在响应中是唯一的(它只出现一次)吗?
If it does you may simply use Regular Expression Extractor added to the HTTP Request which returns json response, with regex like following: 如果是这样,你可以简单地使用正则表达式提取器添加到HTTP请求,返回json响应,正如下面的正则表达式:
HTTP Request
Regular Expression Extractor
Reference Name: authToken
Regular Expression: "authorizationToken":"(.+?)"
Template: $1$
Match No.: 1
and refer further extracted value as ${authToken}
. 并将进一步提取的值称为${authToken}
。
But if your case is more complicated and there several appearances of authorizationToken
in json response and you have to extract concrete one you may use eg BeanShell PostProcessor / BSF PostProcessor added to the same HTTP Request to extract value with beanshell code + json processing library . 但是如果你的情况更复杂并且在json响应中出现了几个authorizationToken
并且你必须提取具体的一个,你可以使用例如BeanShell PostProcessor / BSF PostProcessor添加到相同的HTTP请求以使用beanshell代码+ json处理库提取值。
If not - the first solution above should help. 如果不是 - 上面的第一个解决方案应该有帮助
UPDATE: 更新:
At the moment the most comfortable way to process JSON responses seems to be custom JSON utils for jmeter (JSON Path Assertion, JSON Path Extractor, JSON Formatter) which are also part of Jmeter Plugins . 目前,处理JSON响应的最舒适方式似乎是jmeter(JSON Path Assertion,JSON Path Extractor,JSON Formatter)的自定义JSON utils ,它们也是Jmeter插件的一部分。
In this particular case you can use JSON Path Extractor . 在这种特殊情况下,您可以使用JSON Path Extractor 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.