In my jmeter
test, the test receives the following json
response.
{"result":"success","additional-info":"{\"external-profile\":{\"email\":\"myemail@gmail.com\",\"firstname\":\"fn\",\"lastname\":\"ln\",\"portfolio\":{\"tags-of-interest\":[],\"question-created-tags\":[{\"tag\":\"un2-new tag-empty\",\"count\":1},{\"tag\":\"un2-new tag2-empty\",\"count\":1}],\"question-answered-tags\":[]}}}"}
I want to check that the message has path additional-info.exernal-profile.portfolio
and that there are keys tags-of-interest
, question-created-tag
,question-answered-tag
I am using json jmes path
but I am getting error Assertion failure message:Invalid argument type calling "keys": expected object but was null
What am I doing wrong?
Just go for 2 JSON JMESPath Extractors:
Extract the content of additional-info
attribute into a JMeter Variable from the response
Extract the attributes from the external-profile
attribute:
You can see the extracted values using Debug Sampler and View Results Tree listener combination:
Be aware that since JMeter 3.1 you should be using JSR223 Test Elements and Groovy language for scripting as:
More information: Apache Groovy - Why and How You Should Use It