My Json structure is like below.
How can i extract id of project whose name is ansible using jq?
The json file is very big
https://stedolan.github.io/jq/manual/
{
"id": 38,
"name": "ansible",
"path": "ansible",
"description": "Ansible playbooks, roles, and supporting tools repos"
},
{
"id": 18,
"name": "Analytics",
"path": "analytics",
"description": "Big Data Analytics projects"
}
Assuming your input is actually an array of those objects, you could do this:
$ jq --arg name "ansible" '.[] | select(.name == $name).id' input.json
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With