更新时间:2023-02-23 09:56:33
您可以使用getpath
函数.使用paths
标识通向.comments
的所有路径并获取路径的值
You can use the getpath
function. Use paths
to identify all the paths leading upto .comments
and get the paths' value
jq '[ getpath ( paths | select( .[-1] == "comments" ) ) ]'
或者使用递归下降来过滤包含.comments
的对象并获取其值
Or use a recursive descent to filter objects containing .comments
and get its value
jq '[ recurse | select(has("comments")?).comments ]'