1
votes

We're using Gatling jsonpath in scala to parse our JSON, and are using it like so as per the docs:

val jsonSample = (new ObjectMapper).readValue("""{"@a":"A","@b":"B"}""", classOf[Object])

JsonPath.query("$.@a", jsonSample).right.map(_.toVector)

However, this code fails, and we get an error message about "string matching regex '[$_\d... etc etc }]* expected, but @ found".

I've tried using backslashes, but these do not work and give the same error message. Does anyone know how to escape the @ symbol?

It's worth noting I also tried the solution with hex on this page, but it doesn't work for the above. How do you escape the @ symbol in jsonpath?

Thanks!

1

1 Answers

1
votes

Turns out using a different syntax fixes this:

JsonPath.query("$['@a']", jsonSample).right.map(_.toVector)