Sample Header Ad - 728x90

Is there an equivalent of python's enumerate in jq?

5 votes
2 answers
511 views
I want to get the value *after* a selected item in a list in jq. Something like this seems like it would work:
jq '. as $list | select(.focused == true) | .id as $id | $list | select(????)
One way of doing this would be to enumerate entries like Python - is there a way of doing this. In python enumerate takes [x0, x1, x2, x3, ...] -> [(0, x0), (1, x1), ...] . Another way would be an equivalent of itertools itertools.dropwhile
Asked by Att Righ (1412 rep)
May 3, 2025, 07:36 PM
Last activity: May 5, 2025, 03:03 PM