# Extract values from .json file

**URL:** <https://community.gatling.io/t/extract-values-from-json-file/6047>\
**Category:** Gatling (Open-Source)\
**Created:** [April 7, 2021, 12:50pm UTC](https://community.gatling.io/t/extract-values-from-json-file/6047 "2021-04-07T12:50:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![srinivas\_magapu](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@srinivas\_magapu](https://community.gatling.io/u/srinivas_magapu)\
**Post date:** [April 7, 2021, 12:50pm UTC](https://community.gatling.io/t/extract-values-from-json-file/6047/1 "2021-04-07T12:50:12Z")

</div>

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.

{  
“id”:485,  
“productLine”:"",  
“documentRenders”:[{  
“id”:,  
“queueRetryCount”:0,  
“processStartTime”:“2021-04-06T10:47:57.000+00:00”,  
“pageRenders”:[{  
“id”:95183221,  
**"pageLoc":“[httP://www.test.com](httP://www.test.com)”,**  
“pageNumber”:2,  
“failureReason”:“null”  
},{  
“id”:220,  
**"pageLoc":“[httP://www.test.com](httP://www.test.com)”,**  
“pageNumber”:1,  
“failureReason”:“null”  
}],  
“manufacturingTemplate”:“null”  
}]

}

Thanks & Regards,  
SrinivasM

---

<div class="post-metadata">

**Author:** ![sbrevet](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/sbrevet/32/830_2.png) [@sbrevet](https://community.gatling.io/u/sbrevet)\
**Post date:** [April 7, 2021, 1:01pm UTC](https://community.gatling.io/t/extract-values-from-json-file/6047/2 "2021-04-07T13:01:45Z")

</div>

Hi,

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)

Cheers!

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [April 7, 2021, 1:11pm UTC](https://community.gatling.io/t/extract-values-from-json-file/6047/3 "2021-04-07T13:11:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![srinivas\_magapu](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@srinivas\_magapu](https://community.gatling.io/u/srinivas_magapu)\
**Post date:** [April 7, 2021, 1:15pm UTC](https://community.gatling.io/t/extract-values-from-json-file/6047/4 "2021-04-07T13:15:29Z")

</div>

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.

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

```

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

```

```auto
Thanks & Regards,

```

```auto
Srinivas

```

---

<div class="post-metadata">

**Author:** ![srinivas\_magapu](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@srinivas\_magapu](https://community.gatling.io/u/srinivas_magapu)\
**Post date:** [April 7, 2021, 1:17pm UTC](https://community.gatling.io/t/extract-values-from-json-file/6047/5 "2021-04-07T13:17:55Z")

</div>

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,  
SrinivasM

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [April 7, 2021, 1:59pm UTC](https://community.gatling.io/t/extract-values-from-json-file/6047/6 "2021-04-07T13:59:27Z")

</div>

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](https://github.com/playframework/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.
