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
2.1m questions
2.1m answers
60 comments
57.0k users