So, although there are cases where Anchor/Reference pairs work via Jackson @JsonIdentityInfo, looks like even simple cases sometimes fail.
For example
static class ScratchModel {
public StringHolder foo;
public StringHolder boo;
}
@JsonIdentityInfo(generator = ObjectIdGenerators.None.class)
static class StringHolder {
public String value;
@Override
public String toString() {
return value;
}
}
public void testObjectIdUsingNative() throws Exception
{
final String YAML_CONTENT =
"foo: &foo1\n" +
" value: bar\n" +
"boo: *foo1\n";
ScratchModel result = MAPPER.readValue(YAML_CONTENT, ScratchModel.class);
assertNotNull(result);
}
fails with
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `com.fasterxml.jackson.dataformat.yaml.failing.ObjectId63Test$StringHolder` (although at least one Creator exists): no String-argument constructor/factory method to deserialize from String value ('foo1')
at [Source: (StringReader); line: 3, column: 6] (through reference chain: com.fasterxml.jackson.dataformat.yaml.failing.ObjectId63Test$ScratchModel["boo"])
...
So, although there are cases where Anchor/Reference pairs work via Jackson
@JsonIdentityInfo, looks like even simple cases sometimes fail.For example
fails with