arraysjsonjmeterextractor

Jmeter JSON Extractor for Value based off another Value in Array


I have a JSON body response filled with hundreds of entries like this:

[
  {
    "id": "773",
    "content": {
      "SP_VX": {
        "content": "SOAP Test 1234",
        "dateUpdated": "2021-06-05T17:42:54.325+0000"
      }
    },
    "organTrack": null
  }
]

I am trying to do a cleanup effort from old test runs. I want to extract the id as a variable for every entry that has the words "SOAP Test" in the content field. The words "SOAP Test" are used in multiple entries with a differing numerical id next to it in each entry. I'm not sure how to write the JSON path expression to achieve this.

I tried this but it didn't work: $..[?(@.content==SOAP Test)].code


Solution

  • You won't be able to extract a part of an attribute using either JSONPath or JMESPath as the functionality of splitting a string or substring is not there (yet?)

    It is possible to do this using "normal" Regular Expression Extractor like this: SOAP Test (\d+)

    enter image description here