JSON - jq
# Displaying nested keys:
This is highly useful when dealing when large JSON structure which can contain multiple nested keys. For instance, if you wanted to know what set of JSON keys lead to a value of 'XYZ', the below command would provide the keys in the format A.B.C=XYZ Note: You may encounter integers 0,1,2,etc. This basically indicates the presence of multiple values for the key i.e. Arrays "[]".
jq -r 'paths(scalars | true) as $p | [ ( [ $p[] | tostring ] | join(".") ), ( getpath($p) | tojson )] | join(": ")' > json.paths
Last updated
Was this helpful?