Created
August 28, 2014 13:38
-
-
Save robertberry-zz/e4e9d57fd4eee0e6e505 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
sealed trait Foo | |
case class Bar(a: Int) extends Foo | |
case class Baz(b: Int) extends Foo | |
object FooJson { | |
def fromFoo(foo: Foo) = foo match { | |
case Bar(a) => FooJson("bar", Some(a), None) | |
case Baz(b) => FooJson("baz", None, Some(b)) | |
} | |
} | |
case class FooJson( | |
`type`: String, | |
a: Option[Int], | |
b: Option[Int] | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment