Extract values from .json file

Hi Team,

I have a requirement where I have to capture all the values of a key from a json file. Below is the json file data, in which I have to capture “pageLoc” values.

How can we extract multiple values of a key from a json file.

Please help in addressing this.



Thanks & Regards,


This question is not on gatling subject and does not belong to this mailing list.
Try searching a library to parse json in JVM world. (not only scala but java as well)


What do you mean exactly by “file”?
An entry on the filesystem, or the body of an HTTP response?

Hi Sebastien,

Thank you. Actually I am working on gatling, came across this scenario. In one of the case we could able to get data from Json as below.

val name: JsValue = json \ "user" \ "name"

With this we could able to get one value, but not all the values of that key.

Thanks & Regards,


Hi Stephane,

file - .json file as input from /src/data
Note: from HTTP response I could able to get values with jsonpath, but from file how do we get the values of a key.

Thanks & Regards,

Then Sébastien’s answer is correct.
This is not a question about Gatling, hence not something we can help with.
This is a generic programming question about parsing a JSON file in Scala or Java.

The line of code you shared seems to be using play-json. I recommend you have a look at their tutorials.
Otherwise, you could use Jackson and parse your file in Java. Again, you can find plenty of resources out there.