I have the following situation.
import shapeless.{:+:, CNil}
import julienrf.json.derived.{DerivedOWrites, DerivedReads, NameAdapter}
case class A(i : Int)
case class B(s : String)
object Event {
type AllEvent = A :+: B :+: CNil
implicit def allFormats[T](implicit dr: DerivedReads[T], dw: DerivedOWrites[T]): OFormat[T] = derived.oformat[T](NameAdapter.snakeCase)
}
case class C(id : String, event : Event.AllEvent)
and I want to be able to parse the following json into a C
import play.api.libs.json.{Json, OFormat}
import Event.allFormats
val json = Json.parse(
"""{
"id" : "id",
"event":{
"i" : 1
}
}"""
).as[C]
However I'm getting the error
Error: No Json deserializer found for type C. Try to implement an implicit Reads or Format for this type.
).as[C]
It appears to be struggling to resolve a reads for A :+: B :+: CNil
.
Whatever I try doesn't seem to work. Am I missing something obvious.