Gary Sieling

Get array from JSON in Scala Play

You can extract arrays from Json objects in Scala Play if you cast to JsArray, like so:

val speakers = (obj \ "speakerName_ss").toOption match {
  case Some(x: JsValue) => {
    x.asInstanceOf[JsArray].value
  }
  case None => {
    List()
  }
}
Exit mobile version