我有一个Map [String,List [String]]类型的对象。应该很容易序列化。事实上,如果我在项目目录中运行控制台,我可以这样做:
scala> import play.api.libs.json._
import play.api.libs.json._
scala> Json.toJson(Map("ab" -> List("yo", "yo2", "yo3"), "cd" -> List("hi", "hi1", "hi2")))
res1: play.api.libs.json.JsValue = {"ab":["yo","yo2","yo3"],"cd":["hi","hi1","hi2"]}
哪个好。但是IntelliJ(Ultimate)抱怨说
No Json serializer found for type scala.collection.Map[String,List[String]]. Try to implement an implicit Writes or Format for this type.
即使相同的导入play.api.libs.json._在那里。我很困惑。任何提示?
答案 0 :(得分:1)
相当蹩脚:问题是scala.collection.Map和scala.Predef.Map(== scala.collection.immutable.Map)之间的(隐藏)不匹配。我希望它更加明显。