Skip to content

Commit

Permalink
Merge remote-tracking branch 'FasterXML/2.19'
Browse files Browse the repository at this point in the history
  • Loading branch information
k163377 committed Feb 8, 2025
2 parents b0fe79a + 3322220 commit a1203f3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions release-notes/CREDITS-2.x
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Contributors:
# 2.19.0 (not yet released)

WrongWrong (@k163377)
* #914: Add test case to serialize Nothing? (for #314)
* #910: Add default KeyDeserializer for value class
* #885: Performance improvement of strictNullChecks
* #884: Changed the base class of MissingKotlinParameterException to InvalidNullException
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package tools.jackson.module.kotlin.test.github

import tools.jackson.databind.MapperFeature
import tools.jackson.module.kotlin.jsonMapper
import tools.jackson.module.kotlin.kotlinModule
import kotlin.test.Test
import kotlin.test.assertEquals

class GitHub314 {
// Since Nothing? is compiled as a Void, it can be serialized by specifying ALLOW_VOID_VALUED_PROPERTIES
data object NothingData {
val data: Nothing? = null
}

@Test
fun test() {
val expected = """{"data":null}"""

val withoutKotlinModule = jsonMapper { enable(MapperFeature.ALLOW_VOID_VALUED_PROPERTIES) }
assertEquals(expected, withoutKotlinModule.writeValueAsString(NothingData))

val withKotlinModule = jsonMapper {
enable(MapperFeature.ALLOW_VOID_VALUED_PROPERTIES)
addModule(kotlinModule())
}

assertEquals(expected, withKotlinModule.writeValueAsString(NothingData))
}
}

0 comments on commit a1203f3

Please sign in to comment.