Skip to content

Instantly share code, notes, and snippets.

@debasishg
Created May 13, 2011 17:11
Show Gist options
  • Save debasishg/970916 to your computer and use it in GitHub Desktop.
Save debasishg/970916 to your computer and use it in GitHub Desktop.
// The "in" method returns an AnyRef instead of T in order to support anonymous de-serialization. There may be cases where
// you don't know the exact type of the object, but instead de-serialize it and use extractors. e.g.
val addr = new InternationalAddress("Market Street", "San Francisco", "956871", "USA")
it("should support anonymous deserialization and extraction") {
val a = serializer.in(
serializer.out(addr))
// use extractors
val c = 'city ? str
val c(_city) = a
_city should equal("San Francisco")
val s = 'street ? str
val s(_street) = a
_street should equal("Market Street")
val z = 'zip ? str
val z(_zip) = a
_zip should equal("956871")
val n = 'country ? str
val n(_cnt) = a
_cnt should equal("USA")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment