How can I write the code of an object and for trait ?

38 views
Skip to first unread message

toto

unread,
Jan 14, 2016, 5:59:50 AM1/14/16
to argonaut-json
 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.
Reply all
Reply to author
Forward
0 new messages