Created
July 3, 2018 11:21
-
-
Save regiskuckaertz/0d6591320c1a8d26e983918022d5e9e3 to your computer and use it in GitHub Desktop.
Scanamo format for streamlining JSON values to strings
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
object PlayJsonDynamoFormat { | |
implicit val format: DynamoFormat[JsValue] = DynamoFormat.xmap[JsValue, String]( | |
x => Try(Json.parse(x)) match { | |
case Success(y) => Right(y) | |
case Failure(f) => Left(TypeCoercionError(t)) | |
} | |
)(Json.stringify(_)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment