, . , , :
[leaf_paths as $path | {
"key": $path | map(tostring) | join("_"),
"value": getpath($path)
}] | from_entries
: paths
- , , , , : - , . leaf_paths
- , "", , .
, [[1, 2]]
, paths
[0], [0, 0], [0, 1]
( [1, 2]
, 1
2
), leaf_paths
[0, 0], [0, 1]
.
. $path
( ["list", 1, "key2"]
) map(tostring)
( ["list", "1", "key2"]
) join
. "" , : $path
.
, from_entries
, - JSON. , : , .
, , , . jq-, : , (-s
) , :
(map(leaf_paths) | unique) as $paths |
map([$paths[] as $path | {
"key": $path | map(tostring) | join("_"),
"value": (getpath($path) // "")
}] | from_entries)[]
, : , slurped object $paths
, , . (//
) .
, !