Skip to content

Instantly share code, notes, and snippets.

@manuelbernhardt
Created February 24, 2015 17:14
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 manuelbernhardt/2940c5d35c0d3e63806c to your computer and use it in GitHub Desktop.
Save manuelbernhardt/2940c5d35c0d3e63806c to your computer and use it in GitHub Desktop.
MagicJSON
trait Command
trait Event
case class A(....) extends Command
case class B(....) extends Command
case class C(....) extends Command
case class D(....) extends Command
case class AA(...) extends Event
case class BB(...) extends Event
case class CC(...) extends Event
case class DD(...) extends Event
> MagicJsonLibrary.toJson(A(...))
==> { "$type: "foo.bar.A", "field1": "Foo", "field2": "Bar"}
MagicJsonLibrary.parse("""{ "$type: "foo.bar.A", "field1": "Foo", "field2": "Bar"}""")
==> A(field1 = "Foo", field2 = "Bar")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment