简体   繁体   English

如何使用正则表达式提取器在jmeter中提取json响应数据?

[英]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.

相关问题 如何使用正则表达式提取器提取jmeter中的Json值? - How to extract the Json values in jmeter using regular expression extractor? 如何在jmeter中使用正则表达式提取器从多个数组响应数据中检索JSON值? - How to retrieve the JSON value from multiple array response data using regular expression extractor in jmeter? 如何从jmeter响应中提取正则表达式提取器? - how to extract Regular expression extractor from jmeter response? 如何使用正则表达式提取器从jmeter中的响应中提取值 - how to use Regular expression extractor to extract value from response in jmeter 使用Jmeter中的正则表达式提取器从JSON响应中提取值 - Extracting a value from JSON Response using Regular Expression Extractor in Jmeter 在Jmeter中使用正则表达式提取器提取JSON响应 - Extracting JSON Response using regular expression extractor in Jmeter 使用正则表达式提取器从jmeter响应中提取json - Extracting json from jmeter response using regular expression extractor 使用jmeter中的正则表达式提取器从响应类型的json数据中提取数据 - extract data from reponse typed json data using Regular Expression Extractor in jmeter JMeter 如何使用正则表达式提取器从响应中的项目数组中提取 id - JMeter how to extract ids from array of items from response using regular expression extractor 如何在JMeter中使用正则表达式提取器提取某些值? - How to extract certain values using regular expression extractor in JMeter?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM