Created
January 21, 2015 12:12
-
-
Save debasishg/a2c14c1b63cb18e76e9e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sealed trait Base | |
case class D1(...) extends Base | |
case class D2(...) extedns Base | |
// Have defined all instances of EncodeJson & DecodeJson for D1 and D2 | |
// works in 6.0.x but does not compile in 6.1-M5 since DecodeResult is now invariant | |
implicit val decode: DecodeJson[Base] = DecodeJson { c => | |
(c --\ "storeDelete").as[D1] ||| | |
(c --\ "indexState").as[D2] ||| | |
DecodeResult.fail(s"Unable to decode payload in [$c.asJson]", c.history) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment