Cannot serialize YAML with Deduction-Based Polymorphism #404
Labels
2.15
Fix or feature targeted at 2.15 release
has-failing-test
Indicates that there exists a test case (under `failing/`) to reproduce the issue
yaml
Issue related to YAML format backend
Milestone
I am not able to serialize objects that contain an interface for sub-classes using
@JsonTypeInfo(use = Id.DEDUCTION)
. It works fine for JSON and reading YAML, but when I try to serialize the objects into a Yaml file I get an exception:I created a sample repo that shows the problem here: https://github.com/phaumer/jackson-yaml-deduction
I am working on a configuration file for our product that manages an array of profiles and depending of the type of the profile it would use a different settings object with different properties and sub-objects. The basic structure looks like this
The settings object is declared as
with two implementation classes for the two types of settings.
In the sample repo you see three test cases. The first one reads a sample file as json and writes it back without issues. The second one reads the yaml from above without problems, but throws the exception above when serializing it back with
mapper.writeValue()
.The third example constructions the content as Java objects and can be serialized as json, but not yaml again.
The text was updated successfully, but these errors were encountered: