Skip to content

Instantly share code, notes, and snippets.

@nachinius
Created December 21, 2018 00:54
Show Gist options
  • Select an option

  • Save nachinius/fe2cd2c2efbd1df32f95d2160d380f8e to your computer and use it in GitHub Desktop.

Select an option

Save nachinius/fe2cd2c2efbd1df32f95d2160d380f8e to your computer and use it in GitHub Desktop.
class TestNestedJsonParserTest extends FreeSpec {
"test" in {
case class User(name: String, friends: Seq[User])
lazy val reader: Reads[User] = {
(
(JsPath \ "name").read[String] and
(JsPath \ "friends").lazyRead(Reads.seq[User](reader))
)(User)
}
val jsonText =
"""
|{
| "name" : "nachinius",
| "friends" : [
| {
| "name" : "gato",
| "friends" : []
| }
| ]
| }
""".stripMargin
val b = Json.parse(jsonText).validate[User](reader)
b.isSuccess
println(b.get)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment