Lauritz Hilsøe
12/18/2019, 2:46 PM<?xml version="1.0" encoding="UTF-8">
<provider version="1.0">
<update id="12313">
<event name="hello" created_at="2019-12-14" />
<event name="world" created_at="2019-12-16" />
<country where="us" created_at="2019-15-16" />
</update>
</provider>
Basically want to end up with a class containing ProviderUpdate(id: String, updates: List<Update>)
where Update
is either an interface, class, sealed class or something, that can either be Event
or Country
or etcWesley Acheson
12/18/2019, 4:13 PMLauritz Hilsøe
12/19/2019, 9:16 AMMatteo Mirk
12/31/2019, 9:17 AM@JsonTypeInfo
and @JsonSubTypes
to declare the expected types:
https://www.mkammerer.de/blog/jacksons-polymorphic-deserialization/
The annotations are the same for JSON, but you’ll need to use an XmlMapper
instead of ObjectMapper