# Feeder which transforms JSON lines into JSON arrays of configurable size

**URL:** https://community.gatling.io/t/feeder-which-transforms-json-lines-into-json-arrays-of-configurable-size/6064
**Category:** Gatling (Open-Source)
**Created:** [April 19, 2021, 12:00pm UTC](https://community.gatling.io/t/feeder-which-transforms-json-lines-into-json-arrays-of-configurable-size/6064 "2021-04-19T12:00:36Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![David\_Koch](https://avatars.discourse-cdn.com/v4/letter/d/ac8455/32.png) [@David\_Koch](https://community.gatling.io/u/David_Koch)
#### Post date: [April 19, 2021, 12:00pm UTC](https://community.gatling.io/t/feeder-which-transforms-json-lines-into-json-arrays-of-configurable-size/6064/1 "2021-04-19T12:00:36Z")

</div>

Hello,

I have a fairly big file composed of one JSON object per line. I am struggling to build a feeder which feeds N lines at a time, transformed into an JSON array of N objects as payload to the HTTP REST API I am trying to load test.

Could someone provide an example of how to do this read/transformation step - ideally without reading the entire file into memory first ?

Thank you in advance,

David

---

<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 19, 2021, 12:14pm UTC](https://community.gatling.io/t/feeder-which-transforms-json-lines-into-json-arrays-of-configurable-size/6064/2 "2021-04-19T12:14:56Z")

</div>

Hello,

I’m not sure to understand what you want to achieve.

A feeder is a mean to centralize data to pick for each user (in their session).

What I understand is that you want to create a body for a request based on some data.

I don’t get the link between your use case and a feeder.

My guess:

- Have a file `src/resources/myData.json` containing an array of possible data.
- Have a function that read N lines (random or not depending on your concern) from `classpath:myData.json`, formatting them as you need
- Use this function in your gatling script to generate the body for your request

I don’t know if this can be useful in your use case.

Cheers!

---

<div class="post-metadata">

### Author: ![David\_Koch](https://avatars.discourse-cdn.com/v4/letter/d/ac8455/32.png) [@David\_Koch](https://community.gatling.io/u/David_Koch)
#### Post date: [April 19, 2021, 2:02pm UTC](https://community.gatling.io/t/feeder-which-transforms-json-lines-into-json-arrays-of-configurable-size/6064/3 "2021-04-19T14:02:25Z")

</div>

Hi Sébastien,

Thank you for your reply. You are suggesting that I don’t use the feeder part of the gatling DSL but rather construct the post bodies using something like [processRequestBody](https://gatling.io/docs/current/cheat-sheet/#http-action-http-body-processRequestBody)?

As for my use case: I just want to iterate over the file taking N lines at a time, wrap those lines in a JSON array and post this as payload to my API until the file is exhausted. I am looking to simulate a server-2-server scenario where I have one client with pooled connections, that’s about it.

Thanks,

David
