In [14]:
case class Dog(name: String, age: Int)
case class DogOwner(dog: Dog, name: String)
In [4]:
load.ivy("com.propensive" %% "rapture-core" % "1.1.0")
load.ivy("com.propensive" %% "rapture-json-jackson" % "1.1.0")
In [12]:
import rapture.json.jsonBackends.jackson._
import rapture.json._
import rapture.core._
import modes.returnTry
import formatters.humanReadable._
In [18]:
// case classes are working just fine...
val d = Dog("Tyler", 15)
val q = DogOwner(d, "Frank")
d.age
In [24]:
// I can serialize a dog...
val dogJS = Json(d).toString
val aDog = Json.parse(dogJS).as[Dog]
In [25]:
// Here, evaluating this fails, even though DogOwner is defined...
// Though the error says I need an implicit serializer, I don't need this in normal ammonite-repl or compiled program.
val dogOwnerJS = Json(q).toString
val dogOwner = Json.parse(dogOwnerJS).as[DogOwner]
In [21]:
// However, if I define case-classes and values in same box, it works...
In [21]:
case class Dog(name: String, age: Int)
case class DogOwner(dog: Dog, name: String)
val d = Dog("Tyler", 15)
val q = DogOwner(d, "Frank")
val asJs = Json(q).toString
val parsed = Json.parse(asJs).as[DogOwner]
println(parsed)
In [ ]: