docs: Use a better input example in the streaming section (#3322)

The introduction says all the usage examples (e.g. of truncate_stream,
etc) in the section use [0,[1]] as input, but they actually use [1,[2]].
["a",["b"]] seems better than [1,[2]] as the string values won't be
confusable with the indexes in <path>.
This commit is contained in:
Thomas Sibley authored and GitHub committed 2025-05-14 20:46:31 +09:00
1 parent a8f27cc4db
commit 931a362f8b
4 files changed
+22 -22

No files matched your search

Generated
+6 -6
View File
@@ -1,5 +1,5 @@
.
.TH "JQ" "1" "January 2025" "" ""
.TH "JQ" "1" "May 2025" "" ""
.
.SH "NAME"
\fBjq\fR \- Command\-line JSON processor
@@ -3791,7 +3791,7 @@ However, streaming isn\'t easy to deal with as the jq program will have \fB[<pat
Several builtins are provided to make handling streams easier\.
.
.P
The examples below use the streamed form of \fB[0,[1]]\fR, which is \fB[[0],0],[[1,0],1],[[1,0]],[[1]]\fR\.
The examples below use the streamed form of \fB["a",["b"]]\fR, which is \fB[[0],"a"],[[1,0],"b"],[[1,0]],[[1]]\fR\.
.
.P
Streaming forms include \fB[<path>, <leaf\-value>]\fR (to indicate any scalar value, empty array, or empty object), and \fB[<path>]\fR (to indicate the end of an array or object)\. Future versions of jq run with \fB\-\-stream\fR and \fB\-\-seq\fR may output additional forms such as \fB["error message"]\fR when an input text fails to parse\.
@@ -3803,9 +3803,9 @@ Consumes a number as input and truncates the corresponding number of path elemen
.
.nf
jq \'truncate_stream([[0],1],[[1,0],2],[[1,0]],[[1]])\'
jq \'truncate_stream([[0],"a"],[[1,0],"b"],[[1,0]],[[1]])\'
1
=> [[0],2], [[0]]
=> [[0],"b"], [[0]]
.
.fi
.
@@ -3818,9 +3818,9 @@ Outputs values corresponding to the stream expression\'s outputs\.
.
.nf
jq \'fromstream(1|truncate_stream([[0],1],[[1,0],2],[[1,0]],[[1]]))\'
jq \'fromstream(1|truncate_stream([[0],"a"],[[1,0],"b"],[[1,0]],[[1]]))\'
null
=> [2]
=> ["b"]
.
.fi
.