Loops/Foreach: Difference between revisions

→‎{{header|jq}}: JSON objects too
(jq)
(→‎{{header|jq}}: JSON objects too)
Line 958:
The idiomatic way in jq to accomplish the task, that is, to generate a stream of the items in an array, is to pipe the array through the ".[]" filter, or to append "[]" to the array, e.g.
<lang jq>example[]</lang>
The .[] filter can also be used to generate a stream of the values of a JSON object,
There are two notable alternatives:
e.g.
{"a":1, "b":2} | .[]
 
produces in turn 1 and 2.
 
There are two notable alternatives to using ".[]":
 
'''Using recurse/1''':
2,496

edits