Skip to content

Instantly share code, notes, and snippets.

@wfaler
Created February 25, 2014 21:25
Show Gist options
  • Save wfaler/9218157 to your computer and use it in GitHub Desktop.
Save wfaler/9218157 to your computer and use it in GitHub Desktop.
// 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