on 2019 Sep 20 8:30 AM
Hi experts! Does anybody know the way we could declare DTOs via beans.xml using custom serializer? For instance, I need support a range of formats of Date, that comes in json format. Currently it is implemented via extending JsonDeserializer and using list of parsers via java class:
private static final DateTimeFormatter FORMATTER = new DateTimeFormatterBuilder()
.append(null, PARSERS).toFormatter();
and then we're able to use it in annotations of declared DTOs like:
@JsonDeserialize(using = CustomJsonDateDeserializer.class)
But via declaration in beans.xml there is no chance to use this way.
Request clarification before answering.
We have same issue to allow different DateFormat. Did you find a solution to include Custom Deserializer class in beans.xml?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dmytro,
beans.xml allow us to declarate the default annotations with using annotations tag
<property name="date" type="java.util.Date">
<annotations>
@JsonDeserialize
</annotations>
</property>I believe that there are should be ability to set into it your custom deserializer or set default (i.e. DateDeserializer) but extend it via your custom...
<bean class="com.test.facades.data.MyTestData">
<import type="com.fasterxml.jackson.databind.annotation.JsonDeserialize"/>
<import type="com.fasterxml.jackson.databind.deser.std.DateDeserializers"/>
<property name="date" type="java.util.Date">
<annotations>
@JsonDeserialize(using=DateDeserializers.DateDeserializer.class)
</annotations>
</property>
</bean>hope this helps,
Igor
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 1 | |
| 1 | |
| 1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.