Reputation: 1197
I have an implicit defined for Reads[Seq[SomeCaseClass]]
in an object:
implicit object myReadsObj extends Reads[Seq[SomeCaseClass]] {
override def reads(js: JsValue): JsResult[Seq[SomeCaseClass]] = js match {
// resulting JsResult[Seq[SomeCaseClass]]
}
}
How do I extract the Reads
from it to pass as an implicit to other function asking for Reads
, reads:Reads[Seq[A]]
?
Upvotes: 0
Views: 40
Reputation: 8539
I am not sure that this answers the question, but myReadsObj
will be used as the Reads
in the following code:
case class SomeCaseClass()
implicit object myReadsObj extends Reads[Seq[SomeCaseClass]] {
override def reads(js: JsValue): JsResult[Seq[SomeCaseClass]] =
JsSuccess(Seq(SomeCaseClass()))
}
val j = Json.parse("""{ "hello": "world" }""")
j.validate[Seq[SomeCaseClass]]
Upvotes: 1