File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
src/test/kotlin/com/fasterxml/jackson/module/kotlin/test/github Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ package com.fasterxml.jackson.module.kotlin.test.github
2+
3+ import com.fasterxml.jackson.databind.MapperFeature
4+ import com.fasterxml.jackson.module.kotlin.jsonMapper
5+ import com.fasterxml.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+ }
You can’t perform that action at this time.
0 commit comments