Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can we Verify Json response using Beanshell in Jmeter?

I am getting Json as a response. Instead of using multiple jsonPath_assertion I want to check it in single beanshell. Each time I am getting Response with different values.

like image 425
ShraddhaJ Avatar asked Mar 03 '26 22:03

ShraddhaJ


1 Answers

I would suggest using JSR223 Assertion and Groovy language instead.

Groovy has built-in JSON support so you will be able to use JsonSlurper class to parse the response like:

def json = new groovy.json.JsonSlurper.parseText(prev.getResponseDataAsString())
// do what you need here

Besides Groovy performs much better than Beanshell and it is recommended to use it for scripting in JMeter. See Groovy Is the New Black for more information.

like image 164
Dmitri T Avatar answered Mar 05 '26 11:03

Dmitri T