Search code examples
jmeterjmeter-5.0jmespath

how to specify nested json path in jmespath and jmeter


My jmeter 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 am trying to validate that a path exists. I am able to validate that the top level path exists but I can't validate that the nested path exsits.

Eg. validating "additional-info" works but "additional-info"."external-profile" doesn't. What am I doing wrong?

This works

enter image description here

This fails with error JMESPATH "additional-info"."external-profile" expected to exist

enter image description here


Solution

  • Just go for 2 JSON JMESPath Extractors:

    1. Extract the content of additional-info attribute into a JMeter Variable from the response

      enter image description here

    2. Extract the attributes from the external-profile attribute:

      enter image description here

    You can see the extracted values using Debug Sampler and View Results Tree listener combination:

    enter image description here