# Access the object from the JsonFeeder in the scenario

**URL:** <https://community.gatling.io/t/access-the-object-from-the-jsonfeeder-in-the-scenario/1998>\
**Category:** Gatling (Open-Source)\
**Created:** [February 11, 2015, 3:19pm UTC](https://community.gatling.io/t/access-the-object-from-the-jsonfeeder-in-the-scenario/1998 "2015-02-11T15:19:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Johan\_Dahlberg](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@Johan\_Dahlberg](https://community.gatling.io/u/Johan_Dahlberg)\
**Post date:** [February 11, 2015, 3:19pm UTC](https://community.gatling.io/t/access-the-object-from-the-jsonfeeder-in-the-scenario/1998/1 "2015-02-11T15:19:09Z")

</div>

Hi!

I have a Json file with feedbacks that I want to use in my scenario. But I have several types of feedback and therefore I have a method called buildMessage where I want to build the request body. But how can I send the json object from the feeder to the buildMessage method?

`  
class FeedbackSimulation extends Simulation {  
val feedbacks = jsonFile(“feedbacks.json”).circular

val httpConf = http  
.baseURL(“[https://localhost:443](https://localhost:443)”)  
.acceptHeader(“text/html,application/xhtml+xml,application/xml;q=0.9,_/_;q=0.8”)  
.doNotTrackHeader(“1”)  
.acceptLanguageHeader(“en-US,en;q=0.5”)  
.acceptEncodingHeader(“gzip, deflate”)  
.userAgentHeader(“Gatling2”)

val scn = scenario(“Handle feedback”)  
.feed(feedbacks)  
.exec(http(“Post Feedback”)  
.post("/api/feedback")  
.body(StringBody(HandleFeedback.buildMessage())).asXML  
)

setUp(  
scn.inject(rampUsers(10) over (60 seconds))  
).protocols(httpConf)  
}  
`

`[{ "type": "gnss", "lat": "61.902885", "lng": "6.714318" }, { "type": "gnss", "lat": "61.902885", "lng": "6.714318" }]`

---

<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:** [February 11, 2015, 3:59pm UTC](https://community.gatling.io/t/access-the-object-from-the-jsonfeeder-in-the-scenario/1998/2 "2015-02-11T15:59:16Z")

</div>

The “type”, “lat” and “lng” will be stored in the Session, so obviously, buildMessage as to take a Session input parameter.  
But if you’re not used to Scala and Gatling, a first step would probably to use our templating engine instead of trying to crash bodies manually.

---

<div class="post-metadata">

**Author:** ![Johan\_Dahlberg](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@Johan\_Dahlberg](https://community.gatling.io/u/Johan_Dahlberg)\
**Post date:** [February 12, 2015, 8:40am UTC](https://community.gatling.io/t/access-the-object-from-the-jsonfeeder-in-the-scenario/1998/3 "2015-02-12T08:40:35Z")

</div>

The messages are completely different based on the type so I think it isn’t very practical with the templating engine unless I write complete messages in my JSON. How would I write to be able to pass the Session on to my buildMessage method. I guess I write “session: Session” as input parameter in the method, but how would I write in the scenario?

/Johan

---

<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:** [February 12, 2015, 8:47am UTC](https://community.gatling.io/t/access-the-object-from-the-jsonfeeder-in-the-scenario/1998/4 "2015-02-12T08:47:30Z")

</div>

See this other thread by Carlos Torres for a programmatic example: [https://groups.google.com/forum/#!topic/gatling/yynWVdOzvBw](https://groups.google.com/forum/#!topic/gatling/yynWVdOzvBw)

---

<div class="post-metadata">

**Author:** ![Johan\_Dahlberg](https://avatars.discourse-cdn.com/v4/letter/j/e19adc/32.png) [@Johan\_Dahlberg](https://community.gatling.io/u/Johan_Dahlberg)\
**Post date:** [February 12, 2015, 9:37am UTC](https://community.gatling.io/t/access-the-object-from-the-jsonfeeder-in-the-scenario/1998/5 "2015-02-12T09:37:22Z")

</div>

It’s working now, thanks for the help.

/Johan
