Parse a JSON response and map it.

Hi community,

I’ld like to ask if there’s anyway to parse a JSONResponse as objects using Scala. The question might be vague (sorry), I’ll explain myslef.

The service returns me a JSON array of objects simular to this one.


“body”:“I am posting something dumb just to test tthe thing”,



I’ld like to loop through those objects so I wrote this code :


.exec(http(“Getting the latest five posts”)
.foreach("${recentFivePosts}", “post”){
session =>
val postType = JsonPath.query("$.type", session(“post”).as[String])
println("post : “+session(“post”).as[String]+”\ntype : "+postType)


The problem is that the variable I saved in the check part (recentFivePosts) is going to be parsed attribute by attribute (and not as full object). So when I JsonPath query the post with “$.type” it returns an empty iterator (as it should)

I could’ve directly used “$…type” and save it from the start, but I need another attribute from the same object to use as a parameter of a http request if the type is equal to “X”.

Hope I made myself clear.
Thank you!

If I understood this correctly, you want to use fetch data and then make post calls calls using that data, if so you need to create a custom feeder where you use external Http client such as scalaj, then parse Json using external library such as Play-Json and then build up the feeder as IndexedSeq[Map[String, String]]