JSR223 Postprocessor to parse json in jmeter

Yeasin Hossain picture Yeasin Hossain · Jan 30, 2015 · Viewed 9.9k times · Source

I have used BSF Postprocessor to parse json in one of my jmeter test files. My code is as follow.

eval('var response = '+prev.getResponseDataAsString());
vars.put("userAccountID", response.ID);

But i have found that BSF post processor reduces Jmeter's performance. So i am going for JSR223 Post processor. I need to know what is the corresponding code for above in JSR223 (JAVA language). Thanks in advance;

Answer

shutdown -h now picture shutdown -h now · May 29, 2015

I suggest to use jsr223 assertion and javascript. Then you can just simply check and parse your data. for example:

var response = SampleResult.getResponseDataAsString();
var jsonOutput = JSON.parse(response);

Now you can simply operate on "jsonOutput".