I'm trying to use Jackson 2.15.2 YAMLFactory
to parse the anchor extension syntax:
sections:
- &packetInfo
name: packetInfo
description: information on a received UDP packet
and then later:
sections:
- <<: *packetInfo
description: something else
But I'm getting:
com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "<<"
, and it's giving all the signs of treating the <<
as any other field name.
If I remove the <<:
like this, it loads ok (without the option to override, of course), so the anchor/reference system is working:
sections:
- *packetInfo
Does Jackson not support <<:
extension/overrides? Or is there a Feature switch I need to turn on that I haven't found yet? I've read that handling these is done by a schema, rather than the parser itself.
Jackson is known to not handle references correctly.
You can use SnakeYAML directly which does support references and the merge key <<
. Jackson uses SnakeYAML under the hood anyway but somehow screws this up.
SnakeYAML has pretty much the same capabilities as Jackson so there isn't much of a reason why you'd need to stick to Jackson.