Can't match "@id" with jsonPath?

jsonPath("/id") matches in { “id” : “123” }, but jsonPath("/@id") doesn’t appear to match in { “@id” : “123” }. Suggestions?

JsonPath uses the XPath notation, where @ describes an attribute.
I honestly don’t know how to handle element names starting with @ with XPath.
Please share if you find out.

Otherwise, you can use regex instead.

In XPath, you can escape the @ character by writing @.


Hmm actually, I’m wrong, sorry, there are mentions of ’ but \ is not true at all, my bad ^^

Yep, I tested that before replying :wink:

Thinking it through (I knew I should have waited before posting), in XML, tags cannot contain the @ character. This is why there’s no escaping for this character, as there is no need to escape it.

Completely out of curiosity, why did you name this field @id instead of id ?

As to why, see

You made a point.
We’ll see if we can find a way to make it work.

I opened an issue, but I’m afraid fixing it might require breaking existing JsonPath, so if we find a solution, it might be for Gatling v2.



Fixed, but only is Gatling 2 (meaning that you’d have to grab a snapshot from CI, see wiki) as I dropped attribute notation support.