0
votes

My http request returns a json similar to this:

{
  "ReturnData": {
    "Foo_ef49f92628083fab6e14545c547bcf38": {
      "ViewId": "Foo_ef49f92628083fab6e14545c547bcf38",
      "ViewName": "Foo"
    },
    "Bar_ef49f92628083fab6e14545c18871839": {
      "ViewId": "Bar_ef49f92628083fab6e14545c18871839",
      "ViewName": "Bar"
    }
  }
}

In JMeter I use the JSON Extractor with the following expression to find the ViewId value of the element with the ViewName Bar.

$.ReturnData[?(@.ViewName == 'Bar')].ViewId

But this isn't working, the variable is empty.

When i write something in the default values field, that value is used so the script part is correct.

I tried a few online jsonPath expression tools and all return the correct value but JMeter doesn't.

Does JMeter use some special syntax here, am i missing something or is there another way to achieve this?

1

1 Answers

0
votes

Ok i found the solution.

$.ReturnData.*.[?(@.ViewName=='Bar')].ViewId

This works as expected.
Btw i found the JSON Path Tester in JMeter which helped a lot.
I still don't understand why the online tools worked but anyway, i'm happy this works now.