I'd like to get a list of all paths available in a JSON document, just to get an idea of the layout of a big json document.
One liners preferred, of course a big jq/python program can do the trick.
Example:
echo '{"k1": {"k12": "v12"}, "k2": {"k21": {"k211": "v211"}}}' | jq -r 'not-so-long-magic-here'
k1
k1.k12
k2
k2.k21
k2.k21.k211
There are variations (not exactly duplicates) of this question like 'all paths matching a given pattern' or 'print paths plus value'.
There is also gron, that prints keys and values colorized.
Use
jq -r 'paths | map(numbers |= "[\(.)]") | join(".")'.For example:
A simpler solution using just
paths | join(".")will render array indices and numeric object keys the same way. That might be not desirable.Credit for both solutions goes to @pmf.