Skip to content

How to use DerivedReads with 2 params? #73

@edrevo

Description

@edrevo

I am trying to migrate from 5.0.0 to 7.0.0, but I see that DerivedReads now has an extra TypeTag parameter. The README contains the following snippet, which I'm not sure works anymore with 7.0.0:

implicit val SecondReads: DerivedReads[Second] = new DerivedReads[Second] {
  def reads(tagReads: TypeTagReads, adapter: NameAdapter) = tagReads.reads("Second", (__ \ "foo").read[Integer].map(foo => Second(foo)))
}

since the compiler in my case is complaining that DerivedReads needs 2 params. Is there any ergonomic way of "ignoring" the second type param? My current code looks like this:

implicit def reads(implicit derivedReads: Lazy[DerivedReads[ApiEventV1]]): Reads[ApiEventV1] =
    derivedReads.value.reads(customTypeTagRead, NameAdapter.snakeCase)

And I would like to basically accept whatever in the second type param, but _ isn't working since the second type param is a generic type.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions