micronaut-core icon indicating copy to clipboard operation
micronaut-core copied to clipboard

@JsonFormat not working for @Emeddable class

Open cgray9 opened this issue 8 months ago • 3 comments

Expected Behavior

For the following class I expect openTime and closeTime to serialize as "HH:mm".

@Embeddable
@Introspected
data class Hours(
    var dayOfWeek: DayOfWeek,

    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm")
    var openTime: LocalTime,

    @JsonFormat(pattern = "HH:mm")
    var closeTime: LocalTime,
    var closed: Boolean = false,
    var alwaysOpen: Boolean = false
)

Actual Behaviour

However it serializes to something like [9,0] like the JsonFormat is completely ignored. I've tried the following with no luck

  • Adding @Introspected
  • Removing shape = JsonFormat.Shape.STRING
  • Looked through previous issues

Steps To Reproduce

I have the following installed in build.gradle

implementation("io.micronaut:micronaut-jackson-databind")
implementation("com.fasterxml.jackson.core:jackson-databind")
runtimeOnly("com.fasterxml.jackson.module:jackson-module-kotlin")

Environment Information

macOS 12.6.7 jdk 17

Example Application

No response

Version

3.9.4

cgray9 avatar Jun 27 '24 22:06 cgray9