yq parent negative indices and root command
Introduced 2026-01-31 · score 0.92
HOW TO USE IT
When a query needs an ancestor, use `parent` with a negative index; use `root` to reference the top-level document. The official docs found do not show runnable syntax for negative `parent` indices or the `root` command.
yq '.a.b.c | parent(2)' <file>WHY THIS HELPS
Reference the top-level document or a parent element while querying structured repository data.
REQUIREMENTS AND LIMITATIONS
- Version: v4.52.1
- parent(n): Returns the parent node; `n` is the number of levels to go up and defaults to 1. Negative values are not documented on this page.
FIRST-PARTY EVIDENCE
- https://github.com/mikefarah/yq/releases/tag/v4.52.1
- https://mikefarah.gitbook.io/yq/operators/parent
Check the installed version and the source before using it. Entry JSON