In jq, how can I convert a JSON to a string with key=value?
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
1.4m articles
1.4m replys
5 comments
57.0k users