Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 11661

JSON element selection using jq - how to do?

$
0
0

I am following the examples online when trying to select elements of that array but something very weird happens.

When I run.issuesData.issues[] it displays the array as expected. Fine.

Then I try to select only the nodes with statusId == 10270. this would give me, as expected result, just the last node.

But the result is the array of the 2 objects having all elements assigned with statusId = 10270.

.issuesData.issues[].statusId="10270"

If I try a slightly different approach like that

.issuesData.issues[].statusId=="10270"

I get an array

falsetrue

and this makes sense because only the second elements fits he criteria. But what I am trying to get is just the element itself or at least the "key"The JSON object is like below.

{"issuesData": {"issues": [      {"id": 3619364,"key": "AIG-1992","hidden": false,"typeId": "1","summary": "XXXXXX","priorityId": "2","done": false,"assignee": "XXXX","assigneeName": "XXXX","hasCustomUserAvatar": false,"autoUserAvatar": {"letter": "B","color": "#d39c3f"        },"color": "#ff0000","epicId": "3557134","epic": "AIG-1","estimateStatisticRequired": false,"statusId": "10370","fixVersions": [          120044        ],"projectId": 49202      },      {"id": 3617950,"key": "AIG-1938","hidden": false,"typeId": "1","summary": "YYYYYY","priorityId": "2","done": false,"assignee": "YYYY","assigneeName": "YYY","hasCustomUserAvatar": false,"autoUserAvatar": {"letter": "F","color": "#7bc1a1"        },"color": "#ff0000","epicId": "3658470","epic": "AIG-574","estimateStatisticRequired": false,"statusId": "10270","fixVersions": [],"projectId": 49202      }    ]  }}

What I am doing wrong here?


Viewing all articles
Browse latest Browse all 11661

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>