Created
March 31, 2016 16:04
-
-
Save gigiigig/79d5e1360b464294f335704c24e258b3 to your computer and use it in GitHub Desktop.
This file contains 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
scala> sealed trait Op | |
defined trait Op | |
scala> case class Foo(s: String) extends Op | |
defined class Foo | |
scala> case class Ciao(i: Int) extends Op | |
defined class Ciao | |
scala> case class Bar(op: Op, b: Boolean) | |
defined class Bar | |
scala> Bar(Ciao(3), false) | |
res6: Bar = Bar(Ciao(3),false) | |
scala> res6.asJson | |
res7: io.circe.Json = | |
{ | |
"op" : { | |
"Ciao" : { | |
"i" : 3 | |
} | |
}, | |
"b" : false | |
} | |
scala> decode[Bar](res7.toString) | |
res8: cats.data.Xor[io.circe.Error,Bar] = Right(Bar(Ciao(3),false)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment