-
Notifications
You must be signed in to change notification settings - Fork 116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MonthDaySerializer does not serialize objects into array #107
Comments
I don't know how to make the MonthDaySerializer serialize an object into an array? |
This belongs under |
|
Thanks, This is the smallest reproduction.
|
From the referenced Spring Boot issue, here's an even smaller reproduction: ObjectMapper objectMapper = new ObjectMapper().enable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS).registerModule(new JavaTimeModule());
System.out.println(objectMapper.writeValueAsString(MonthDay.now()));
System.out.println(objectMapper.writeValueAsString(YearMonth.now()));
System.out.println(objectMapper.writeValueAsString(LocalDateTime.now())); The above code will produce output similar to the following:
|
Has anyone noticed here? |
Ok finally got around to this one. So: for some reason, original implementation defaulted to textual, not array-based, and since there is no way to distinguish "left as default" setting for use-timestamps from explicit, indication has to be done some other way. Former is static class Wrapper {
@JsonFormat(shape = JsonFormat.Shape.ARRAY) // or NUMBER
public MonthDay value;
} and config overrides something like objectMapper.configOverride(MonthDay.class)
.setFormat(JsonFormat.Value.forShape(JsonFormat.Shape.ARRAY); Now: these work, but it seems that deserialization part does NOT actually work at this point. |
Closing this, follow-up under #121. |
Unlike YearMonthSerializer serialize objects as array " [2018, 5]", MonthDaySerializer serialize to "--03-02"
I notice document say, what should i do :
I use org.springframework.boot:spring-boot-starter-web:2.1.3.RELEASE,
com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.8,
com.fasterxml.jackson.module:jackson-module-kotlin:2.9.8
application.yml
The text was updated successfully, but these errors were encountered: