Skip to content

Commit

Permalink
Fix DefaultJson documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
FranAguilarRod committed May 26, 2022
1 parent a7a3860 commit 1a52964
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import kotlin.native.concurrent.*
/**
* The default JSON configuration used in [KotlinxSerializationConverter]. The settings are:
* - defaults are serialized
* - mode is not strict so extra json fields are ignored
* - pretty printing is disabled
* - array polymorphism is disabled
* - keys and values are quoted, non-quoted are not allowed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,19 @@ class JsonSerializationTest : AbstractSerializationTest<Json>() {
)
)
}

@Test
fun testExtraFields() = testSuspend {
val testSerializer = KotlinxSerializationConverter(defaultSerializationFormat)
val dogExtraFieldJson = """{"age": 8,"name":"Auri","color":"Black"}"""
assertFailsWith<SerializationException> {
testSerializer.deserialize(
Charsets.UTF_8,
typeInfo<DogDTO>(),
ByteReadChannel(dogExtraFieldJson.toByteArray())
)
}
}
}

@Serializable
Expand Down

0 comments on commit 1a52964

Please sign in to comment.