guardian / scanamo-scrooge   0.2.1


Automatic DynamoDB serialisation of Scroge generated classes

Scala versions: 2.11

ScanamoScrooge Maven Central Build Status

Like Scanamo for interacting with DynamoDB and use Scrooge for working with Thrift? Then you'll love ScanamoScrooge!

ScanamoScrooge provides automatic derivation of DynamoFormat type classes for Scrooge generated classes based on Thrift struct and enum types.


Add scanamo-scrooge as a dependency to your build.sbt:

libraryDependencies ++= Seq(
  "org" %% "scanamo-scrooge" % "0.1.3"


To bring DynamoFormats for Scrooge generated classes into scope, simply

import org.scanamo.scrooge.ScroogeDynamoFormat._

While, there is normally no need to explicitly reference DynamoFormat, the following is an example of how it serialises classes based on the ChangeRecord thrift definition.

scala> import org.scanamo._
scala> import org.scanamo.scrooge.ScroogeDynamoFormat._
scala> import
scala> import cats.syntax.either._

scala> val changeRecord = ChangeRecord(1L, Some(User("email", Some("f"), None)))
scala> DynamoFormat[ChangeRecord].write(changeRecord)
res0: = {M: {date={N: 1,}, user={M: {email={S: email,}, firstName={S: f,}, lastName={NULL: true,}},}},}

scala> DynamoFormat[ChangeRecord].read(DynamoFormat[ChangeRecord].write(changeRecord))
res1: Either[error.DynamoReadError, ChangeRecord] = Right(ChangeRecord(1,Some(User(email,Some(f),None))))