$ jq '[to_entries[]|{"key":.value.attributes.name,"value":.key}]|from_entries' fruit_ip.txt { "David's apple": "192.168.144.52", "David's banana": "192.168.144.40" } $ jq '[.[]|{(.attributes.name):.ipAddress}]|add' fruit_ip.txt { "David's apple": "192.168.144.52", "David's banana": "192.168.144.40" } $ jq -r "to_entries|map(\"\(.value.attributes.name) = \(.key)\")|.[]" fruit_ip.txt David's apple = 192.168.144.52 David's banana = 192.168.144.40