问题
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: "(.*?)"
回答1:
Just add closing quotation mark to your regular expression as
token": "(.*?)"
and use $1$
as Template
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
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.
回答2:
Extracting token value from the response
So here I you used as User id so please change this in token so and use post processor regular expression it will definitely work
回答3:
Use
"token":"(.+?)"
in the JSON Path Extractor.
回答4:
In regular expression extractor use regular expression as token": "([^"]+)" and template $1$. I hope this will help you.
来源:https://stackoverflow.com/questions/30450712/jmeter-how-to-extract-token-id-from-response-data