I have a command that outputs multiple simple json objects like this (for development purposes previously piped to a file foo.txt):
$ cat foo.txt
{"a": "b"}
{"a": "e"}
{"a": "f"}
Now I would like to get it formatted like this:
{
"a": ["b", "e", "f"]
}
I am pretty sure it can be done with jq, but all I can get is the following:
$ cat foo.txt |jq -n '.a |= [inputs]'
{
"a": [
{
"a": "b"
},
{
"a": "e"
},
{
"a": "f"
}
]
}
Any hints?
.aconstant or it could change/dynamic ?ais constant, not changing.