I have a simple JSON object and would like to convert it into a properties file in bash.
Input:
{
"foo": "bar",
"abc": "def ghi"
}
expected output:
foo="bar"
abc="def ghi"
You can use to_entries
for that:
jq -r 'to_entries[]|"\(.key)=\"\(.value)\""' input.json
Btw, in Java properties files you don't need to quote the value:
jq -r 'to_entries[]|"\(.key)=\(.value)"' input.json