Created
February 25, 2014 21:25
-
-
Save wfaler/9218157 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// how to decode case objects and UUID in the example below? Encoding works fine. | |
sealed trait Foo | |
case object Bar extends Foo | |
case object Baz extends Foo | |
case class SomeThing(uuid: UUID, foo: Foo) | |
implicit def SomeThingCodec = casecodec2(SomeThing.apply,SomeThing.unapply)("uuid", "foo") | |
implicit def UUIDEncodeJson = new EncodeJson[UUID]{ def encode(uuid: UUID) = jString(uuid.toString)} | |
implicit def UUIDDecodeJson = new DecodeJson[UUID]{} // probably stackoverflows here | |
implicit def FooEncodeJson = new EncodeJson[Foo]{ def encode(foo: Foo) = jString(foo.toString)} | |
implicit def FooDecodeJson = new DecodeJson[Foo]{} // and here |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment