Skip to content

2.10.1 seems to output JSON field where name of function matches name of private field #270

@daviddenton

Description

@daviddenton

Behaviour change, this code produces a different result to 2.10.0, where field would not be rendered:

data class Wrapper(private val field: String) {
    val upper = field.toUpperCase()
    fun field() = field
    fun stillAField() = field
}

fun main() {
    println(
        ObjectMapper()
            .registerModule(KotlinModule())
            .writeValueAsString(Wrapper("hello"))
    )
}

produces:

{"field":"hello","upper":"HELLO"}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions