In jq, how can I convert a JSON to a string with key=value
?
From:
{
"var": 1,
"foo": "bar",
"x": "test"
}
To:
var=1
foo=bar
x=test
You could try:
jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' test.json
Here's a demo:
$ cat test.json
{
"var": 1,
"foo": "bar",
"x": "test"
}
$ jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' test.json
foo=bar
var=1
x=test