Skip to content

Instantly share code, notes, and snippets.

@TheRyanBurke
Last active December 10, 2015 23:09
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 TheRyanBurke/4507821 to your computer and use it in GitHub Desktop.
Save TheRyanBurke/4507821 to your computer and use it in GitHub Desktop.
nested scala classes -> jerkson parse/generate -> store/retrieve in cassandra.io
class Address(street: String, street2: String, city: String, state: String, zip: String) {}
class User(email: String, shippingAddress: Address, billingAddress: Address) {}
def storeUser(user: User) = {
val userjson = jerkson.generate(user)
// put this userjson in cassandra
WS.url(URL + "/" + java.util.UUID.randomUUID()).post(userjson)
}
def retrieveUser(id: String): User = {
val response = WS.url(URL + "/" + id).get()
jerkson.parse[User](response.body)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment