Skip to content

objectMapper.writeValueAsString does not properly serialize Kotlin data class variables that begin with "is" Β #575

@skwirskj

Description

@skwirskj

Describe the bug

When calling the objectMapper's writeValueAsString and passing a Kotlin data class to the function, any of the variables that begin with "is" such as "isDayTime" and that is a string type, do not retain its values after serialization. This was observed after using the serialized body in a GET request to a private API where the API threw an error due to missing required parameters. This does work though if the variable is a boolean.

To Reproduce

  1. Create a Kotlin data class with at least one variable of String type, starting with "is"
  2. Create an instance of the data class and an instance of the Jackson Object Mapper
  3. Serialize the data and pass to an API. API should come back with some error if the value is required.

Expected behavior

The objectMapper would serialize the data class as expected and would retain the value, regardless of the naming convention of a variable.

Versions
Kotlin: 1.7.10
Jackson-module-kotlin: 2.13.3
Jackson-databind:

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions