我想在play framwork 2.6.x中将Map转换为Json。 代码就像
def toJson(x:Map[String, Object]) = {
import play.api.libs.json._
Json.toJson(x)
}
我收到错误No Json serializer found for type Map[String,Object]. Try to implement an implicit Writes or Format for this type.
我添加writes
,代码变为:
def toJson(x:Map[String, Object]) = {
import play.api.libs.json._
implicit val writes = Json.writes[Map[String, Object]]
Json.toJson(x)
}
我遇到了错误。 No apply function found for scala.collection.immutable.Map