Skip to content

Instantly share code, notes, and snippets.

@rodolfo42
Last active August 29, 2015 14:07
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 rodolfo42/2116f533980859f6ccd5 to your computer and use it in GitHub Desktop.
Save rodolfo42/2116f533980859f6ccd5 to your computer and use it in GitHub Desktop.
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"
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