Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jackson skips isXXX properties 2.11.x or higher #422

Closed
SusumuKanazawa opened this issue Mar 5, 2021 · 1 comment
Closed

Jackson skips isXXX properties 2.11.x or higher #422

SusumuKanazawa opened this issue Mar 5, 2021 · 1 comment
Labels

Comments

@SusumuKanazawa
Copy link

Describe the bug
when json serialize, isXXX properties is deleted.
This bug has been fixed in 2.10.1, but it may have been degraded 2.11.x or higher.
#346
#337

To Reproduce
create new project in IntellJ IDEA.

build.gradle.kts

dependencies {
    implementation(kotlin("stdlib"))
    implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.11.+") // or 2.12.+
}

src/main/kotlin/Test.kt

import com.fasterxml.jackson.annotation.JsonProperty
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import com.fasterxml.jackson.module.kotlin.readValue
import java.lang.Exception

data class MyData(
    @JsonProperty("id")
    val id: String,
    @JsonProperty("isValue")
    val isValue: Int,
    @JsonProperty("isStringValue")
    val isStringValue: String
    )

fun main() {
    val jsonString = """
        { "id": "id001", "isValue": 1, "isStringValue": "20" }"
        """.trimIndent()

    val mapper = jacksonObjectMapper()

    try {
        val parseData: MyData = mapper.readValue(jsonString)
        println("parseJson")
        println(parseData)

        val jsonData = mapper.writeValueAsString(parseData)
        println("toJson")
        println(jsonData)
    } catch(e: Exception) {
        e.printStackTrace()
    }
}

resutls:

parseJson
MyData(id=id001, isValue=1, isStringValue=20)
toJson
{"id":"id001"}

isXXX is deleted.

Expected behavior
change to 2.10.+

dependencies {
    implementation(kotlin("stdlib"))
    implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.10.+")
}

results:

parseJson
MyData(id=id001, isValue=1, isStringValue=20)
toJson
{"id":"id001","isValue":1,"isStringValue":"20"}

isXXX is exists.

Versions
Kotlin: 1.4.30
Jackson-module-kotlin: 2.11.+, 2.12.+
Jackson-databind:
IntellJ IDEA: 2020.2.3

@dinomite
Copy link
Member

dinomite commented Mar 6, 2021

We'll continue to track this in #337

@dinomite dinomite closed this as completed Mar 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants