Skip to content

Commit

Permalink
json KeyWrites using SameRuntime
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Sep 14, 2024
1 parent 1b3a95d commit 44d5d7a
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions playJson/src/main/scala/Json.scala
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ object Json:
)(using NotGiven[NoJsonHandler[T]]): Format[T] =
format.bimap(bts.apply, stb.apply)

given [A](using sr: SameRuntime[A, String]): KeyWrites[A] with
def writeKey(key: A) = sr(key)

private val stringFormatBase: Format[String] = Format(Reads.StringReads, Writes.StringWrites)
private val intFormatBase: Format[Int] = Format(Reads.IntReads, Writes.IntWrites)

Expand Down

0 comments on commit 44d5d7a

Please sign in to comment.