Jmeter components ATLANTBH: JSON path statement

I am trying to execute a JSON statement using the ATLANTBH jmeter JSON PATH Assertion.
However, I cannot write the correct expression to get the following fields from the JSON feed below:

  • 123456789
  • 1009
  • SOME RANDOM MESSAGES

    {"api": {"status":"Success","callsremaining":36,"version":"xxxx"} ,"result":{"errors":{"123456789":{"code":1009,"error":"SOME RANDOM MESSAGE"}}} } 

Anyone have experience using this JMeter plugin?
I know that I could use regex and Beanshell for validation, but I would rather use this JSON Path Assertion.

Any help you could provide would be most appreciated.

+7
source share
1 answer

It looks like you can easily assert the values 1009 and SOME RANDOM MESSAGE using JSONPath expressions (in the JSON Path Assertion components), but you are not sure about 123456789 : this is not a node value, but the name is bode, and the JSONPath implementation used by these components does not seem to be has expressions to get the name node.

Suppose you can easily use 123456789 for approval instead of associating a JSON Path Extractor (from the same component collection) with the jmeter Response_Assertion standard.

  • Add 2 JSON Path Assertions as children of the sampler that returns the json response you want to handle:

    enter image description here

    enter image description here

    The expressions will be $.result.errors..code and $.result.errors..error respectively.

  • Add the JSON Path Extractor as a child of the same sampler to retrieve the full error record:

    enter image description here

    Expression: $.result.errors. .
    This will extract {"123456789":{"error":"SOME RANDOM MESSAGE","code":1009}} and save it to a pointed variable ( ${errorKey} ).

  • Add the response response as a child to the same sampler, after adding the JSON Path Extractor:

    enter image description here

    This will indicate the key name ( 123456789 ) in the value of the variable ${errorKey} .


So, the final design may look like

 ... YOUR Sampler JSON Path Extractor JSON Path Assertion JSON Path Assertion Response Assertion ... 
+3
source

All Articles