Skip to content

Commit

Permalink
Fix json generic record decoding (zio#453)
Browse files Browse the repository at this point in the history
  • Loading branch information
paulpdaniels authored Dec 5, 2022
1 parent 6cd2a72 commit c4aa3c0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,7 @@ object JsonCodec {
val value = schemaDecoder(schema).unsafeDecode(trace_, in)
builder += ((JsonFieldDecoder.string.unsafeDecodeField(trace_, label), value))
case None =>
Lexer.char(trace, in, ':')
Lexer.skipValue(trace, in)

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,15 @@ object JsonCodecSpec extends ZIOSpecDefault {
}
)
),
suite("generic record")(
test("with extra fields") {
assertDecodes(
recordSchema,
ListMap[String, Any]("foo" -> "s", "bar" -> 1),
charSequenceToByteChunk("""{"foo":"s","bar":1,"baz":2}""")
)
}
),
suite("transform")(
test("string") {
val stringSchema = Schema.Primitive(StandardType.StringType)
Expand Down

0 comments on commit c4aa3c0

Please sign in to comment.