laserdisc-io / scanamo-circe

Providing circe-based scanamo DynamoFormat instances

Version Matrix


Build Release Maven Central

This is a small library providing circe implementations of Scanamo's DynamoFormat, converting your models to and from Scanamo AttributeValues.

This allows full use of DynamoDB while allowing arbitrary Json objects to be stored or reusing existing formats.


Add the dependency:

libraryDependencies += "io.laserdisc" %% "scanamo-circe" % "2.0.1"

Then import the desired instance wherever you invoke Scanamo operations

import io.laserdisc.scanamo.circe.CirceDynamoFormat._

Note: This imports an implicit DynamoFormat[T], which will expect an implicit circe Encoder[T] and Decoder[T] in scope.

CirceDynamoFormat and null object values

CirceDynamoFormat is this project's default implementation, which encodes null Json values as the equivalent dynamodb null representation, i.e. { "NULL": true}.

This behaviour is undesirable when the attribute in question is in use by a sparse index. When saving a model for which the sparse index attribute is { "NULL": true}, the following error will occur:

One or more parameter values were invalid: Type mismatch for Index Key foo Expected: S Actual: NULL

In this case, we may wish to simply drop such null attribute values instead of encoding them to the explicit NULL type.
The following import brings an instance which discards all null object values during write.

import io.laserdisc.scanamo.circe.CirceDropNullDynamoFormat