trait FirstTrait extends globaltrait
case class theFirst extends FirstTrait
case class theSecond extends FirstTrait
case object the firstobject extends FirstTrait {val t = 1}
case object theSecondObject extends FirstTrait{val g = 54}
I have the codec of class theFirst and the codec of class theSecond but I don't khnow How I will write the codec of the firstobject and the second for write the codec of FirstTrait .
implicit def codecFirstTrait: CodecJson[FirstTrait] =
CodecJson[FirstTrait](
{
case c1: theFirst => theFirstCodec encode c1
case c2 :theSecond=> theSecondCodec encode c2
case the firstobject => ???
case theSecondObject => ???
},
c => (theFirstCodec.widen[FirstTrait] decode c) |||
(theSecondCodec .widen[FirstTrait] decode c) |||
(the firstobject.widen[FirstTrait] decode c) |||
(theSecondObject.widen[FirstTrait] decode c)
)
How Write the codec of Object and of trait ???
thanks.