I have this data. {"bucket":"sdsd","key":"hghghg","region":"us-east-1"} I want to convert it into following format. using shell commands.
- "bucekt"="sdsd"
- "key"="hghghg"
- "region"="us-east-1"
CodePudding user response:
Use to_entries
to access keys and values. To escape with quotes, it may not be sufficient to just put quotes around the names. Depending on your use case, converting to JSON strings using @json
might be an option:
jq -r 'to_entries[] | @json "\(.key) = \(.value)"'
"bucket" = "sdsd"
"key" = "hghghg"
"region" = "us-east-1"