jq: filter input based on if key ends with specified string jq: filter input based on if key ends with specified string json json

jq: filter input based on if key ends with specified string


to_entries is worth knowing about, not least because it often leads to easy-to-read (variable-free) pipelines, as here:

to_entries[] | select(.key|endswith("/")) | .value.type


jq solution:

jq -r '. as $o | keys_unsorted[] | select(endswith("/")) | $o[.].type' file.json

The output:

tokenuserpass