Created
January 17, 2015 01:21
-
-
Save propensive/abf6eaef3fc071a5c7a2 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
| Welcome to Scala version 2.10.4 (OpenJDK 64-Bit Server VM, Java 1.6.0_27). | |
| Type in expressions to have them evaluated. | |
| Type :help for more information. | |
| scala> import rapture.json._; import jsonBackends.scalaJson._ | |
| import rapture.json._ | |
| import jsonBackends.scalaJson._ | |
| scala> class SpecialInt(val i: Int) extends AnyVal | |
| defined class SpecialInt | |
| scala> val myJson = json"""{ "value": 42 }""" | |
| myJson: rapture.json.Json = {"value":42} | |
| scala> myJson.value.as[SpecialInt] | |
| res0: SpecialInt = SpecialInt@2a | |
| scala> val newJson = json"""{ "output": $res0 }""" | |
| newJson: rapture.json.Json = {"output":42} | |
| scala> case class Foo(first: Int, second: SpecialInt) | |
| defined class Foo | |
| scala> json"""{ "first": 1, "second": 2 }""".as[Foo] | |
| res2: Foo = Foo(1,SpecialInt@2) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment