[英]Get key names from JSON file recursively using jq
我可以使用jq
作为顶级 JSON 键
jq 'keys'
例如,看到这个问题: Get key names from JSON file using jq
我可以在jq
启用递归:
jq '..'
如: 按键递归搜索值
但是jq '.. | keys'
jq '.. | keys'
返回jq: error at <stdin> string has no keys
。
当 JSON 中的某些值不存在键时,只需忽略键:
jq '.. | keys?'
检查键名时忽略非对象:
jq -r '.. | if type == "object" then to_entries[] | .key else empty end' "${LOCALAPPDATA}/Google/Chrome/User Data/default/Bookmarks" | sort --uniq
bookmark_bar
checksum
children
date_added
date_modified
guid
id
name
other
roots
synced
type
url
version
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.