Json File body
[
{
"customer": {
"id": 12,
"name": "Sam"
"info": [T]
},
"customer": {
"id": 13,
"name": "Same"
"info": [T]
},
}
]
Gatling scenario
val checkCustomer: ChainBuilder = {
.feed(existingCustomerInJson.circular)
.exec{ session =>
newSession = session.set("customerWithBodyForCheck", buildBody(session("customer").as[Map[String, Any]]))
newSession
}
.exec(sendRequestForCeckCustomer)
Convert Map to Object
import org.json4s.native.Serialization
import org.json4s.native.Serialization.read
def buildBody(customer:Map[String, Any]): String ={
implicit val formats = Serialization.formats(org.json4s.NoTypeHints)
def mapToObject[A: Manifest](map: Map[String, Any]): A = {
val jsonString = Serialization.write(map)
read[A](jsonString)
}
val customerObject: T = mapToObject[T](customer)
BodyForCheckCustomer(
id = customerObject.customer.id,
info = customerObject.customer.info
).toString.mkString // or can use circe
}
case class BodyForCheckCustomer(
id: Int
info: Any
)