Reputation: 53
I'm trying to write a JSON parse using lift-web and scala. I mapped my JSON to several case classes (for nested values/types), but I'm stuck with a MappingException error. This is the nested part of the JSON i'm trying to parse:
...
"attachments":[{"8a7d22ff":"Image1.png"}],
...
for which I specified the following parameter in the case class
case class myType(
...
attachments: List[(String,String)]
...
)
Unfortunately, I got this message:
Caused by: net.liftweb.json.MappingException: Expected collection but got JObject(List(JField(8a7d22ff,JString(Image1.png)))) for root JObject(List(JField(8a7d22ff,JString(Image1.png)))) and mapping Constructor(TypeInfo(class scala.Tuple2,Some(class scala.Tuple2[class java.lang.String,class java.lang.String])),List(DeclaredConstructor(public scala.Tuple2(java.lang.Object,java.lang.Object),List(Arg(_1,Value(class java.lang.String),false), Arg(_2,Value(class java.lang.String),false)))))
at net.liftweb.json.Meta$.fail(Meta.scala:227)
at net.liftweb.json.Extraction$.newCollection$1(Extraction.scala:330)
at net.liftweb.json.Extraction$.build$1(Extraction.scala:400)
at net.liftweb.json.Extraction$.mkValue$1(Extraction.scala:431)
... 30 more
I also tried Map[String,String] but nothing, I do not really understand which datatype I've to put for parsing JSON with dynamic types...Any idea?
Upvotes: 2
Views: 124