I have this input data:
[
{
"attributes": {
"created": "2021-10-18T12:02:39+00:00",
"enabled": true,
"expires": null,
"notBefore": null
},
"contentType": null,
"id": "https://kjkljk./secrets/-/1",
"managed": null,
"name": "pw",
"tags": {}
},
{
"attributes": {
"created": "2021-10-18T12:06:16+00:00",
"enabled": true,
"expires": null,
"notBefore": null
},
"contentType": "",
"id": "https://kjklj./secrets/-/2",
"managed": null,
"name": "pw",
"tags": {}
}
]
I need to use jq to extract the id values into a new array where enabled is set to true. this is what I have so far:
.[] | select(any(.attributes; .enabled== true)) | {id}
but it only results in this:
{
"id": "https://kjkljk./secrets/-/1"
}
{
"id": "https://kjklj./secrets/-/2"
}
how can i make these two objects into an array of strings instead?
[
"id": "https://kjkljk./secrets/-/1",
"id": "https://kjklj./secrets/-/2"
]
[ "id": "https://kjkljk./secrets/-/1", "id": "https://kjklj./secrets/-/2" ]isn't valid JSON. You said "array of strings", so did you mean[ "https://kjkljk./secrets/-/1", "https://kjklj./secrets/-/2" ]?