jmeter how to use json path extractor

Viewed 913

I'm new to jmeter.
I want to save the value of the key in a variable, if the id is 7106 from the following response

[{"id":"MAIN","key":1},
{"id":"87","city":"Roselle","key":1000,"state":"IL"},
{"id":"7102","city":"Chicago","key":110,"state":"IL"},
{"id":"7106","city":"Crown Point","key":110038,"state":"IN"},
{"id":"7108","city":"Indianapolis","key":1139,"state":"NJ"}]

How to do it in jmeter?

3 Answers

Add post Processor - JSON Extractor to your sampler and create a variable of any name, in JSON Path expression give value = $..key , this should extract all values that "key" holds.

Now add View Result Tree to see all variables created, suppose you give variable name as "key" , all values should be stored as key_1, Key_2 and so on..

you can use any value now, as in your case it would be ${key_4} . Adding picture for your help

JSON Extractor

Related