Skip to content

Commit a1203f3

Browse files
committed
Merge remote-tracking branch 'FasterXML/2.19'
2 parents b0fe79a + 3322220 commit a1203f3

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

release-notes/CREDITS-2.x

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Contributors:
1818
# 2.19.0 (not yet released)
1919

2020
WrongWrong (@k163377)
21+
* #914: Add test case to serialize Nothing? (for #314)
2122
* #910: Add default KeyDeserializer for value class
2223
* #885: Performance improvement of strictNullChecks
2324
* #884: Changed the base class of MissingKotlinParameterException to InvalidNullException
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package tools.jackson.module.kotlin.test.github
2+
3+
import tools.jackson.databind.MapperFeature
4+
import tools.jackson.module.kotlin.jsonMapper
5+
import tools.jackson.module.kotlin.kotlinModule
6+
import kotlin.test.Test
7+
import kotlin.test.assertEquals
8+
9+
class GitHub314 {
10+
// Since Nothing? is compiled as a Void, it can be serialized by specifying ALLOW_VOID_VALUED_PROPERTIES
11+
data object NothingData {
12+
val data: Nothing? = null
13+
}
14+
15+
@Test
16+
fun test() {
17+
val expected = """{"data":null}"""
18+
19+
val withoutKotlinModule = jsonMapper { enable(MapperFeature.ALLOW_VOID_VALUED_PROPERTIES) }
20+
assertEquals(expected, withoutKotlinModule.writeValueAsString(NothingData))
21+
22+
val withKotlinModule = jsonMapper {
23+
enable(MapperFeature.ALLOW_VOID_VALUED_PROPERTIES)
24+
addModule(kotlinModule())
25+
}
26+
27+
assertEquals(expected, withKotlinModule.writeValueAsString(NothingData))
28+
}
29+
}

0 commit comments

Comments
 (0)