我需要从User(1,Nick Holland,25,None)
获取一个对象List(Map())
,但我不知道如何
val a = request.body.asFormUrlEncoded.toSeq.map(a => a.map(b => b))
List(Map(name -> ArrayBuffer(), age -> ArrayBuffer(), deleteItem -> ArrayBuffer(User(1,Nick Holland,25,None)), action -> ArrayBuffer(remove)))
答案 0 :(得分:1)
尝试
case class User(i: Int, str: String, i1: Int, opt: Option[String])
val l = List(Map("name" -> ArrayBuffer(), "age" -> ArrayBuffer(), "deleteItem" -> ArrayBuffer(User(1,"Nick Holland",25,None)), "action" -> ArrayBuffer("remove")))
l.head.apply("deleteItem").head //User(1,Nick Holland,25,None)