YAML Anchors / References
See original GitHub issueHi there, first of all thanks heaps for your awesome work with Jackson.
I am trying to get a concise configuration out of a yaml file, but I am pretty stuck at the moment.
I have followed many issues and still did not managed to get it working using only @JsonIdentityInfo
By the this tests it should be as simple as annotating Environment
class with @JsonIdentityInfo(generator = ObjectIdGenerators.StringIdGenerator.class)
but that also did not work.
After reading this issue i thought it could be the scope, so I have annotated the environment
and bundle1
properties adding the main Configuration
class as scope but that also yield not success.
Is this possible today, if it is how can it be achieved, and if not what do you recommend?
As the issue 266 suggests, I should write my own DeserializationContext
, and figure out a way to find the references. But “you” --I believe it is you-- recommended this before.
Which of these two should I follow if there is no simple way to get it working with the current 2.9.6 version?
Trying to debug I did not see any calls to bindItem
which means that SimpleObjectIdResolver._items
are always null, even though I can see the references being set what would trigger that line to be called? Please keep in mind that I don’t claim to know anything about jackson, that was what I could gather from trying to debug it.
name: "dropwizard-app"
environment: &environment
profile: "dev"
provider: "aws"
segment: "segment"
security-context: "test"
region: "us-east-1"
bundle-1: &bundle1
environment: *environment
path: "x/y/z"
bundle-2:
# property-config-1: (optional)
endpoint: "https://my-service-1"
bundle-1-configuration: *bundle1
PS. Like the tests I have also tried the anchoring as a prefix, but it seems that the library have no issues finding both ways.
Thanks again.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:14
- Comments:11 (5 by maintainers)
Created 2 new issues to possibly address this:
JsonNode
(“Tree Model”)YAML only allows backward references: spec says “It is an error for an alias node to use an anchor that does not previously occur in the document.” (“alias” node here is the usage of a reference, and “anchor” is it’s definition). However, it is allowed to redefine anchors. Thus as I see it, a single pass could resolve all the references.