Array: Difference between revisions

Content added Content deleted
Line 71: Line 71:
Assuming a and b are arrays, and if m and n are non-negative integers:
Assuming a and b are arrays, and if m and n are non-negative integers:
<lang jq>
<lang jq>
[][n] # => an array with n nulls
[][n] = null # => an array with (1+n) nulls
[range(0;n)] # => [0,1, ... (n-1)]
[range(0;n)] # => [0,1, ... (n-1)]
a | length # => the length of a
a | length # => the length of a
Line 78: Line 78:
a[-1] # => the last element (or null)
a[-1] # => the last element (or null)
a[m:n] # => the subarray [a[m], ..., a[n-1]]
a[m:n] # => the subarray [a[m], ..., a[n-1]]
</lang>
</lang>

====Streams and Arrays====
====Streams and Arrays====
jq provides support for streams of JSON entities, and thus the syntax for converting between an array and the stream of entities that an array contains is fundamental to jq. In brief:
jq provides support for streams of JSON entities, and thus the syntax for converting between an array and the stream of entities that an array contains is fundamental to jq. In brief: