Extracting Hash from JSON, saved into session, cannot be converted to Map

Using Gatling 2.2.0 (pre-release version)

There an API that contains locations which is Hash/Map of String to Int. I have saved this into a session attribute. I am trying to extract the keys from this Hash for building out other API calls. But, I am getting stuck extracting the value from the session attribute.


“locations”: {
“/href/10592”: 373,
“/href/10663”: 6032,
… }



Using println, I can see that this Session attribute looks like:

locs → {"/href/10592":373,"/href/10663":6032, …}


Solved this by using a session function to parse the string into a JSON object.

val labels = session(“locs”).as[String]
val json:Option[Any] = JSON.parseFull(labels)
val labelsVector: Vector[String] = json.get.asInstanceOf[Map[String, Int]].keys.toVector

Bad idea. Perf killer. Use ofType[]. Can’t explain more, I’m on mobile. Please search the doc.