Skip to content

Commit

Permalink
Fix DefaultJson to ignore unknown keys
Browse files Browse the repository at this point in the history
  • Loading branch information
FranAguilarRod committed May 24, 2022
1 parent a7a3860 commit 43b5149
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public val DefaultJson: Json = Json {
allowStructuredMapKeys = true
prettyPrint = false
useArrayPolymorphism = false
ignoreUnknownKeys = true
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,16 @@ class JsonSerializationTest : AbstractSerializationTest<Json>() {
).let { result ->
assertEquals("""{"a":"1","b":["c",2]}""", result.decodeToString())
}

val dogExtraFieldJson = """{"age": 8,"name":"Auri","color":"Black"}"""
assertEquals(
DogDTO(8, "Auri"),
testSerializer.deserialize(
Charsets.UTF_8,
typeInfo<DogDTO>(),
ByteReadChannel(dogExtraFieldJson.toByteArray())
)
)
}

@Test
Expand Down

0 comments on commit 43b5149

Please sign in to comment.