Last active
August 29, 2015 14:07
-
-
Save rodolfo42/2116f533980859f6ccd5 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
name := "Rapture.io talk" | |
libraryDependencies += "com.propensive" %% "rapture-io" % "0.10.0" | |
libraryDependencies += "com.propensive" %% "rapture-json-jawn" % "1.0.2" | |
libraryDependencies += "com.propensive" %% "rapture-net" % "0.10.0" | |
libraryDependencies += "com.propensive" %% "rapture-codec" % "1.0.0" |
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._ | |
import core._, io._, net._, uri._, json._, codec._ | |
import jsonBackends.jawn._ | |
import encodings.`UTF-8` | |
object Test extends App { | |
// entities | |
case class Bands(groups: Seq[Band]) | |
case class Band(groupName: String, members: Seq[BandMember]) | |
case class BandMember(name: String, born: Int) | |
case class BandMembers(members: Seq[BandMember]) | |
// parse url | |
val jsonUri = uri"http://rapture.io/sample.json" | |
// consume | |
val result = jsonUri.slurp[Char] | |
val json = Json.parse(result) | |
// works | |
json.groups.as[Seq[Band]] | |
json.groups().members.as[Seq[BandMember]] | |
// doesnt work | |
// json.as[Bands] | |
// json.groups().as[BandMembers] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment