How can I access nested JSON variable in Karate fed from Gatling?

Viewed 146

I have a JSON File feeder which has JSON that is nested like:

{
  "id": "X",
  "context": {
    "id": "Y"
  },
  "username": "Z"
}

And I can successfully access the id and username in my Karate file using: #(__gatling.id) etc. However, when I try and access #(__gatling.context.id) it comes up null.

Gatling has obviously parsed it into a Map but I'm unclear now how to access this variable?

1 Answers

I don't know how you are setting up the feeder data. Here is the example in the docs: https://github.com/intuit/karate/tree/master/karate-gatling#feeders

val feeder = Iterator.continually(Map("someKey" -> "someValue"))

And then #(__gatling.someKey) would work. So try the Map (JSON) like this and it should work. And please use the new 1.0 RC stream as this is going to be released soon: https://github.com/intuit/karate/wiki/1.0-upgrade-guide

If it still doesn't work, please follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

Related