Last active
August 29, 2015 14:07
-
-
Save lrytz/4fb1e66a171013f69fd8 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
scalaVersion := "2.11.2" | |
libraryDependencies ++= Seq("com.propensive" %% "rapture-json-jackson" % "1.0.2") |
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
import rapture.json._ | |
import rapture.json.jsonBackends.jackson._ | |
case class Fruit(name: String, variants: List[String]) | |
object Rapture extends App { | |
val a = json"""[ | |
{ | |
"name": "apple", | |
"variants": ["cox", "braeburn"] | |
}, | |
{ | |
"name": "orange", | |
"variants": ["valencia", "hamlin"] | |
} | |
]""" | |
println(a(1).name) | |
println(a(0).variants.as[List[String]] map (_.length)) | |
val b = a.as[List[Fruit]] | |
println(b) | |
val c = Json(b.head) | |
assert(c == a(0)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use version 1.0.3 now -- I found a bug with case class extraction in 1.0.2 a couple of days ago!