Use map_values
instead of map
to map the values of a JSON object while preserving the keys:
jq '.p | map_values(keys)'
On jq versions lower than 1.5, map_values
is not defined: instead, you can use []|=
:
jq '.p | . []|= keys'
Use map_values
instead of map
to map the values of a JSON object while preserving the keys:
jq '.p | map_values(keys)'
On jq versions lower than 1.5, map_values
is not defined: instead, you can use []|=
:
jq '.p | . []|= keys'