Skip to content

Fields defined in scala object and trait are not serialized #495

Closed
@yufangong

Description

@yufangong

In the process of bumping Jackson version from 2.11.2 to 2.12.0, we have noticed this behavior change:

trait TraitWithoutJsonProperty {
  val name = "name1"
}
object ObjectWithoutJsonProperty extends TraitWithoutJsonProperty {
  val value = "value1"
}

This ObjectWithoutJsonProperty on 2.11.2 will be serialized with fields value, but not on 2.12.0.

2.11.2 output: {"value":"value1","name":"name1"}
2.12.0 output: {}

We also find out that adding @JsonProperty annotation can write the fields, however, it can be hard for us to detect our customer's usage.

The full reproduce example is located here.
Thank you!

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