JsonPath doesn't accept @


I’m trying to do a jsonPathCheck but it seems not to work with my regex.

The code below

JsonPath.query("$.object[*].@id","{“object”: [{"@id": “3”,“nom”: “object3”}]}")

produce the response below

Left(JPError(string matching regex [$_\p{L}][$_\-\d\p{L}]*' expected but @’ found))

“object”: [
@id”: “3”,
“nom”: “object3”

So you’re trying to directly use our JsonPath implementation, not through Gatling APIs, right?

JsonPath.query second element is an AST, not a String => a tree of Maps and Lists that have already been parsed.

I use the check of Gatling in the way below :
I’v replaced below the real args by “…”.
But i’ve the same result with JsonPath.query(…)

That code worked well with the version : 2.0.0-M3a but not with 2.0.0-RC6

.headers(Map(“token” → “${token}”))


2M3a was using Jayway’s JsonPath implementation, which is both inefficient and broken (doesn’t respect the jsonPath specification).
So we implemented our own.

$.object[*].@id is not a valid expression as @ is a reserved character in JsonPath: “the current object/element”. Basically, it shouldn’t have worked in the first place.

As a consequence, you have to use the bracket notation so you can pass the attribute name in a protected String:

Thanks for your answers.

I know it, but I did not want to do it now.
I will have to refactor some pieces of code to avoid the ‘@’ char.

It doesn’t work with [’@id’]

It doesn't work with ['@id']

Well, I really looks to me that it does:

Are you sure you don't have a typo on your side such as a dot between the

Proper path is $.object[*]['@id']

Thanks a lot, you were right with the dot.

My job works fine now.