Hey all, coming across a very strange bug with a Kotlin data class that's being serialized to a JSON response using Jackson. I have a bool on the data class
isMyFeautureEnabled
and when the data class gets serialized, there are two booleans serailzed
isMyFeatureEnabled
and a phantom field
myFeatureEnabled
(without the is). If I change the name of
isMyFeatureEnabled
to something like
testFieldName
, then I don't see the phantom field. Anyone come across this before?
So:
data class MyData(
val field1: String,
val field2: String,
val isMyFeautureEnabled: Boolean,
)
serializes to:
{
"field1": "test",
"field2": "test",
"isMyFeatureEnabled": true,
"myFeatureEnabled": true
}
but
data class MyData(
val field1: String,
val field2: String,
val testField: Boolean,
)
serializes to:
{
"field1": "test",
"field2": "test",
"testField": true
}
Not sure if it's a Kotlin thing or a Jackson thing but it must be something to do with the
is
in the name.