scala - Gatling - convert json response to List of case classes -
gatling 2.0. i'receiving server following json of events:
[ { "a":"a","b":"b","c":"c","d":"d"}, { "a":"a1","b":"b1","c":"c1","d":"d2" }, { "a":"a2","b":"b2","c":"c2","d":"d3" } ]
now store in session list of event classes
case class event(a:string:b:string,d:string)
i'm trying following
jsonpath("$.chats.chat[0].events.event").oftype[seq[any]].transform(_.map{ l => some(event(l(0).asinstanceof[string], l(1).asinstanceof[string],l(3).asinstanceof[string])).saveas("events")
but line not compile: please help.
after fetch list session, can by:
val events = session("events").as[seq[events]]
thanks.
you're using transform, takes extract result , transform else.
here, don't specify check ordinality, use default, find
, first result of extraction step. doubt $.chats.chat[0].events.event
want, return map (a javascript object). want $.chats.chat[0].events
.
then regarding, storing , accessing data session, shouldn't try storing them in classes if you're not used scala.
instead, upgrade gatling 2.1 has improved el capabilities, can write things ${event.foo.bar}
(which can't gatling 2.0).
Comments
Post a Comment