Last active
August 29, 2015 14:05
-
-
Save teodanciu/64cf4ff0f1859f917bb5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test { | |
case class User(name: String, age: Int) | |
implicit val formats = Json.formats | |
implicit val validate: Validate[User] = Validate[User]() | |
implicit val read: Read.Json[User] = Read.reflect[User] | |
val json = Json.parseJObject( | |
s""" | |
|{ | |
| "body": [ | |
| {"name": "N1", "age": 1}, | |
| {"name": "N2", "age": 2} | |
| ] | |
|} | |
""".stripMargin | |
) | |
println(Read.fromJArray[User]((json \ "body").to[JArray].getOrThrow)) | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: Failure(ArrayBuffer(FieldError(field-missing,The field is missing.,Field(List([0], $outer)))))