0

I need to parse a json into a couple possible case classes:

trait Request {...}
case class RequestOne(...) extends Request
case class RequestTwo(...) extends Request

I created a request wrapper:

trait RequestModel {
    type T <: Request 
    def parse(input: JValue): T = input.extract[T]
}

object RequestOneModel extends RequestModel {
    type T = RequestOne
}
object RequestTwoModel extends RequestModel {
    type T = RequestTwo
}

With an idea to have RequestModels with the type [T] to parse to inside them.

The code above throws "No Manifest available for RequestModel.this.T."

Dmytro Mitin
  • 48,194
  • 3
  • 28
  • 66
Martee
  • 77
  • 10

1 Answers1

1

Try to add an implicit parameter to the method

trait RequestModel {
  type T <: Request
  def parse(input: JValue)(implicit manifest: Manifest[T]): T = input.extract[T]
}
Dmytro Mitin
  • 48,194
  • 3
  • 28
  • 66