How can I make a key value dictionary using jq?
If I do: cat api_fm.json | jq -r "[ .[].name, .[].status ]"
I receive:
[
"plugin",
"c_docker_2",
"c_docker_5",
"c_docker_4",
"c_docker_3",
"c_docker_1",
"Started",
"Started",
"Started",
"Started",
"Started",
"Started"
]
So, I would like to map the name with the status like this:
[
"plugin: started"
...
]
2
Answers
Here is one way:
Working through the requirements in your comment. Given:
We can produce tab-separated name-status pairs like
Then, to create the bash associative array