jsonPath with $ as part of attribute name


I’m trying out Gatling, and what I am currently trying to do is to get the object id from a json object. The data is stored in a MongoDB, and thus the id is an ObjectId which is presented as “$oid”: “”

Example data:

[{"_id":{"$oid": “520e2f0645665d1a52308e16”},“orderRows”:[{“itemNumber”:“abc123”,“lineType”:“4”}],“companyNumber”:1}]

The JSONPath Expression tester (http://jsonpath.curiousconcept.com/) correctly can dig out the id using $[0]._id.$oid

But trying the same in Gatling .check(jsonPath("$[0]._id.$oid") results in Request ‘request1’ failed : jsonPath($[0]._id.$oid).exists() didn’t match: found nothing

Any idea what could be wrong here?

Replying to myself here.

A work-around for this is to instead write it as: $[0]._id[’$oid’]

It looks like the $ messes up with the JsonPath expression has it has a special meaning. This could also be a Jayway’s JsonPath implementation bug.
Note that we are working on our own implementation that will closely match Goessner’s specification.

Thanks for the workaround with the array notation.