The title says it all: A jq program takes an input JSON document whose structure I'm only vaguely familiar with, and I want it to print the path to all properties within it that have a certain name.
The title says it all: A jq program takes an input JSON document whose structure I'm only vaguely familiar with, and I want it to print the path to all properties within it that have a certain name.
Older question here, but this very much my typical use case.
For a solution for this specific type of problem see:
https://github.com/TomConlin/json_to_paths
usage e.g.
json2jqpath.jq file.json | grep "certain_name"
Basically reduces an arbitrary .json file into
the full list of paths addressable within it.
Also allows converting to like xml-xpath-like strings
and creating GraphVis renderings of the json structure.
One caveat is if there are empty arrays you will have to
append you own ? to the [] to make them optional.
newer versions figure it out in most cases