Jmeter-如何从响应数据中提取令牌ID [英] Jmeter- How to extract token id from Response Data

查看:119
本文介绍了Jmeter-如何从响应数据中提取令牌ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我需要从中提取令牌值的响应数据

This is the response data from which i need to extract token value

{
  "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0IjoibXljb21wYW55IiwiZCI6ImhrZy5maXJlYmV0LmRldi5zdXBwb3J0LmNvbSIsInBybSI6WyJsb2c6KiIsInNlc3Npb246Y29ubmVjdCIsInNlc3Npb246dXBsb2FkRmlsZToxMjUyMyIsInNlc3Npb246ZGV2aWNlSW5mbyxsb2dhY3Rpdml0eWV2ZW50LGRldmljZWNhcGFiaWxpdHk6MTM1MTEiXSwianRpIjoiMGVmNmU5OGYtZjQ0My00NmEzLTkxMmMtMDNiNmMyZDFjNzU1IiwiYXBwIjoiVGVzdGFwcCIsInZlciI6IjEiLCJwbHQiOiJBbmRyb2lkIiwiaWF0IjoxNDMyNjE4MDY3LCJhdWQiOiJhcHAiLCJleHAiOjE0MzI2MjUyNjcsImlzcyI6IlN1cHBvcnQuY29tIn0.qkgSrZFoc2MR8xQN0boRd85PcmD1R0xkQjVzKXNv2Uk",
  "session_device_id": "13511",
  "session_id": "12523",
  "relay_config": "tdssd:443",
  "symmetric_key": "dssdFx0=",
  "workflow_version_id": 10s008,
  "unique_connection_id": "fsdsd"
}

当前我正在使用正则表达式提取器

Currently I am using regular expression extractor

token: "(.*?)"

推荐答案

只需将正引号添加为正则表达式

Just add closing quotation mark to your regular expression as

token": "(.*?)"

并使用$1$作为模板

另一种选择是使用 JSON路径提取器. //jmeter-plugins.org/"rel =" nofollow> JMeter插件,它更方便从JSON响应中提取内容.在这种情况下,请使用以下JSON路径查询:

Another option is using JSON Path Extractor which comes with JMeter Plugins which is more handy to extract stuff from JSON responses. In that case use the following JSON Path query:

$..token

请参见在JMeter中使用XPath提取器指南(向下滚动至"JSON解析"),以获取有关JSON Path语言的更多信息以及一些有用的示例.

See Using the XPath Extractor in JMeter guide (scroll down to "Parsing JSON") for more information on the JSON Path language and few useful examples.

这篇关于Jmeter-如何从响应数据中提取令牌ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆