Skip to content

Instantly share code, notes, and snippets.

@teodanciu
Last active August 29, 2015 14:05
Show Gist options
  • Save teodanciu/64cf4ff0f1859f917bb5 to your computer and use it in GitHub Desktop.
Save teodanciu/64cf4ff0f1859f917bb5 to your computer and use it in GitHub Desktop.
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))
}
@teodanciu
Copy link
Author

Output: Failure(ArrayBuffer(FieldError(field-missing,The field is missing.,Field(List([0], $outer)))))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment