Skip to content

Commit

Permalink
ToJson[MaybeJsonSyntax] (#64)
Browse files Browse the repository at this point in the history
Fix #63
  • Loading branch information
nrktkt authored Feb 29, 2024
1 parent bdf4208 commit f5f4022
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions ninny/src/nrktkt/ninny/ToJsonInstances.scala
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ trait ToJsonInstances
implicit val uuidToJson: ToSomeJsonValue[UUID, JsonString] =
uuid => JsonString(uuid.toString)

implicit val syntaxToJson: ToJson[MaybeJsonSyntax] = _.maybeJson
}
object ToJsonInstances extends ToJsonInstances

Expand Down
7 changes: 7 additions & 0 deletions ninny/test/src/nrktkt/ninny/ToJsonInstancesSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,11 @@ class ToJsonInstancesSpec extends AnyFlatSpec with should.Matchers {
either.toSomeJson shouldEqual expected
}
}

"MaybeJsonSyntax" should "be usable as JSON" in {
val objxt = obj("nested" ~> obj("name" ~> "value"))
val syntax: MaybeJsonSyntax = objxt.nested
val newObject = obj("outer" ~> syntax)
newObject shouldBe obj("outer" ~> obj("name" ~> "value"))
}
}

0 comments on commit f5f4022

Please sign in to comment.