Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What's the easiest way to map JSON array values to a dictionary using jq?

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"
]

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

So, I would like to map the name with the status like this:

[
"plugin: started"

]

>Solution :

Here is one way:

jq 'map("\(.name): \(.status)")'
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading