Open ryegleason opened 7 years ago
I think the first question is whether this would work with JSON or not: if yes, issue belongs here and is something general. If not, it is likely due to something related to use of "native" type and/or object ids; something that YAML has and JSON does not (and instead has to use generic properties, no data/metadata separation).
Combination should work, and I think there are JSON tests that support this, so I would guess it is more likely to be YAML specific. But would be good to verify: if it occurs with JSON, reproduction and fixing should be easier.
Either json-specific reproduction is needed here; or (more likely?), should be re-created under jackson-dataformats-text
for YAML (https://github.com/FasterXML/jackson-dataformats-text/issues).
Okay, I'll do that. For now and to help any future people who stumble upon this issue, the workaround is to use @JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = JsonTypeInfo.As.WRAPPER_OBJECT, property = "@class")
instead of @JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class")
, property doesn't seem to work but WRAPPER_OBJECT works great.
I'm using 2.9.0.pr3 for all libraries, and the java code looks like this:
in.yml is
and it throws an error of
This should, in theory, be able to work because all the type info is already there, in the referenced object that has already been constructed (should I create a separate FEATURE issue for this?). In practice, I know you have to specify the type info or default implementation. However, there is seemingly no way to specify type info. I annotated Runnable with
@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS, include=JsonTypeInfo.As.PROPERTY, property="@class")
and changed in.yml toand got a SnakeYaml error because it couldn't parse "task". When the order of task and '@class': ImportantTask are flipped, the error is instead