I'm in a scenario where I'm converting from type A
to type B
. Type A
has a date field which is of type YearMonth
, and type B
's date field is a String
. I don't want to reinvent the wheel, so it'd be great if I could use The Jackson DataType JSR310 library for this conversion.
However, I'm quite confused how I can use the YearMonthSerializer
's public serialize
method in a standalone way; same goes for YearMonthDeserializer
's public deserialize
method.
serialize
takes in a YearMonth
(fine) alonside a JsonGenerator
and SerializationProvider
(what?) which I'm not sure how to retrieve, whereas derialize
doesn't even have a String
as an argument, just a JsonParser
and DeserializationContext
.
I don't want to use this library in the typical way @JsonSerialize(using = YearMonthSerializer.class)
because I'm not converting an entire POJO to a JSON sting, just one YearMonth
field to a String
.
Based on these APIs though it almost looks like I am definitely not intended to use the library in this desired way.
Here's a link to the javadoc.