type mismatch with bodyString.transform

Hi I’m trying to convert json to a map using gatlings bodyString.transform. I’m getting a type mismatch error

`
found : Option[String] => Option[scala.collection.mutable.Map[String,String]]

required: String => ?
`

.

post(s"api/v1/$user/account") .queryParam("callback", "hopCallback") .queryParam("commonDomain", commonDomain) .check(status is 200) .check(jsonPath("$.submitUrl").saveAs("hopSubmitUrl")) .check(bodyString.transform(convertHOPJsonToMap).saveAs("hopData")) .check(jsonPath("$.currentTime").exists)

where:

`
def convertHOPJsonToMap(in: Option[String]): Option[mutable.Map[String, String]] = in match {
case Some(json) => {

`

Don’t bother, let Gatling do the job with “ofType”: http://gatling.io/docs/2.1.4/http/http_check.html?highlight=jsonpath

check(jsonPath("$").ofType[Map[String, Any].saveAs(“hopData”)

hm, but i still need to convert.

def convertHOPJsonToMap(in: Option[String]): Option[mutable.Map[String, String]] = in match {
case Some(json) => {
val parsed = JSONValue.parse(json).asInstanceOf[JSONObject]
val fields = parsed.get(“fields”).asInstanceOf[JSONArray]

val result = mutable.MapString, String

for (i ← 0 until fields.size) {
val f = fields.get(i).asInstanceOf[JSONObject]
if (f.get(“name”) != null && f.get(“value”) != null) {
result.put(f.get(“name”).toString, f.get(“value”).toString)
}
}

Option(result)
}
case None => throw new Exception(“No json value.”)
}