-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
spray.json.JsArray to sequence of case classes #259
Comments
Can you define does "not work" mean here? Pasting the compile or runtime errors you encountered would make helping you easier. This works: "works" in {
case class Movie(id: Int, title: String)
import spray.json._
import DefaultJsonProtocol._ // if you don't supply your own Protocol (see below)
implicit val movieFormat = jsonFormat2(Movie)
val x = """
|[
| { "id": 12, "title": "that movie" }
|]
""".stripMargin.parseJson
info("it + " + x.convertTo[Seq[Movie]])
}
|
"not work" -meant that I got the following errors
Followed your instructions, and now I got an error which says...
Any suggestions for next step? |
Apparently I had a problem in my class. Your solution is correct. Thanks |
Happy hakking |
How do I convert a spray.json.JsArray to sequence of case classes?
e.g. I have a variable
movieArray
which is of typespray.json.JsArray
and I would like to turn it into a sequence of Movie case classescase class Movie(id: Int, title: String)
I tried already
movieArray.convertTo[Seq[Movie]]
andmovieArray.map(_.convertTo[Movie])
, but neither seemed to work.The text was updated successfully, but these errors were encountered: