Last active
December 10, 2015 23:09
-
-
Save TheRyanBurke/4507821 to your computer and use it in GitHub Desktop.
nested scala classes -> jerkson parse/generate -> store/retrieve in cassandra.io
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
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