Skip to content

Commit

Permalink
Use flatMap in jsonToBinaryBase64 (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
lenguyenthanh authored Aug 25, 2024
1 parent e706ad9 commit aa99aa7
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private[circe] object CirceJsonMapper extends JsonMapper[Json] {
binaryBase64ToJson(Uuid.toBase64(uuid), "04")

def jsonToBinaryBase64(json: Json): Option[String] =
json.asObject.get(Tag.binary).flatMap(_.asObject).get("base64").flatMap(_.asString)
json.asObject.flatMap(_.apply(Tag.binary)).flatMap(_.asObject).flatMap(_.apply("base64")).flatMap(_.asString)

def jsonToUuid(json: Json): UUID =
Uuid.fromBase64(jsonToBinaryBase64(json).get)
Expand Down

0 comments on commit aa99aa7

Please sign in to comment.