Matching Boolean true value using jsonPath

Viewed 4906

I am trying to write a JUnit test, which checks the value of received JSON. I access these values in the JSON using jsonPath. I want to check if a value is true. For simple jsonPaths, it works for me, but when I write more complex jsonPath query, it does not and I am getting this Assertion Error:

Expected: is <true>
but: was <[true]>

My JSON:

{...
,"trips":
  [
    {...
    ,"employee":{"name":"Ordinary Joe","login":"joe","contractor":true}
    ,...
    },
    ...
  ],
 ...
}

Problematic assertion

.andExpect(jsonPath("$.trips[?(@.employee.login=='joe')].employee.contractor", is(true)));

What I've tried

I tried to match the value also with new Boolean(true), boolean[] array with one true value and after examination of is() matcher also with String.valueOf(true) however it also did not match.

My question

How should I correctly match this true value? What exactly these [] braces mean in the test output?

1 Answers
Related