Closed jj314 closed 2 months ago
Sounds like serializer for LocalDateTime
is not producing expected schema structure for given settings.
Quick note: the issue is due to Schema generation for Array types not working (NOT "Map" like exception claims -- I'll do PR for that minor flaw). This because by default LocalDateTime
is serialize as Array of 3 integers.
Until fix for schema generation to support arrays is added, the best way to work around this is to serialize LocalDateTime
as String
, not array: this can be done f.ex by disabling
SerializationFeature.WRITE_DATES_AS_TIMESTAMPS
setting on ProtobufMapper
.
So: for anyone looking at this issue -- proper fix is to add Protobuf schema generation for Array of JsonFormatTypes.INTEGER
as indicated by JSR310FormattedSerializerBase._acceptTimestampVisitor()
of Date/Time format module.
But test should work by generating schema for, say, int[]
.
Ahhhhh. Not quite even that -- using a wrapper, like:
class LocalDateTimeWrapper {
public LocalDateTime value;
}
would make things work. So it's only for root value that there is an issue.
Ok, now I remember: at root level, Protobuf cannot support Array values -- so as long as type like LocalDateTime
is serialized as array, it cannot be serialized as the root value: it must be a property of a root-level object / record. This also applies if attempting to serialize as a String
, fwtw, fundamental restriction.
Hello, I'm having trouble serializing LocalDateTime with Protobuf.
Here is what I'm trying to do:
but I get the following exception:
pom.xml: