Skip to content

Instantly share code, notes, and snippets.

@sam
Forked from anonymous/CustomFormat.scala
Created June 23, 2014 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sam/9ea4350c33fe6a5b9406 to your computer and use it in GitHub Desktop.
Save sam/9ea4350c33fe6a5b9406 to your computer and use it in GitHub Desktop.
case class Foo(a: String, b: Int)
object Foo {
def apply(a: String, b: String) = new Foo(a, b.toInt)
}
val format = jsonFormat2[Foo](new {
def apply(a: String, b: Int): Foo = Foo(a, b)
def unapply(f: Foo) = Foo.unapply(f)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment