Try adding support for `JsonNode` and full resolution of Object Ids, without need for `@JsonIdentityInfo`
See original GitHub issue(note: lots of background, and follow-up for #98)
So: handling of YAML Anchors, References, is problematic since: JSON has no directly equivalent notion. And although similar logical concept has been added by Jackson – Object Id, via @JsonIdentityInfo
– it is both bit awkward to use and limited in scope (i.e. not handling all cases).
But it might be possible to implement full, no-annotation style resolution just for “Tree Model” (that is, JsonNode
). Since there is already
JsonParser.canReadObjectId()
to indicate if format is capable of expressing Object Ids natively (returning true
for YAML), it might be possible to combine this with another setting that essentially indicates that automatic resolution should be used.
I am not 100% sure if this is indeed doable, especially with 2.x, but I think it is worth exploring.
And with Jackson 3.0 it should be even more likely to be doable.
So. If and when I have time to investigate this, I’d like to see if this can be made.
The obvious corollary, then, would be that much of YAML processing would first use readTree()
(and equivalents) to resolve all references, and then either use that or use mapper.treeToValue()
to get to actual POJOs, ones that need not handle anchors/refs at all.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:4
- Comments:16 (5 by maintainers)
Ah. Yes, there’s that too, good point (I am familiar with that problem from xml context).
It would only be applicable if Object Id was resolved by expanding contents; my original thinking was (… I think) to retain actual identity and use loops. This would not expand size of content, although code using such structures (possibly cyclic graphs, if YAML [and more specifically, SnakeYAML] allows this – I am not sure YAML does actually) would need to be aware that to avoid problems at level.
So ability to prevent expansion probably makes sense no matter what.
It’s not just about resolving external references but generally defending against expansion bombs, cf. https://en.wikipedia.org/wiki/Billion_laughs_attack#Variations