简体   繁体   中英

Extracting json data from Jmeter http request response

I can't find a way to extract array from a json response in Jmeter http request. All other fields i'm able to extract. However something like the following i cannot seem to extract. is there any way i can extract this from response in Jmeter http request? In the following i need to extract [1,2,3] and save it in a variable.

"days":[1,2,3]
"sectionIds":[abc,def,ghi]

something like the folliwing i can just extract using "subscriptionId":"(.+?)" in the jmeter regular expression extractor

"subscriptionId":"abcd"

time value can be extracted using this "time":(\\d+)

"time": 120

I guess you have problem with square braces not being quotted. Try:

"days":(\\[.+?\\])

or if you want to match numbers inside something like:

"days":(\\[(\\d+,?)+\\])

I don't think that Regex way is the best option to deal with JSON data.

There is a plugin called JSON Path Extractor which provides functionality alike to JMeter Embedded XPATH Extractor but targeting JSON.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM