manual.yml: some clarifications plus fixes for markdown bloopers (#2737)
This commit is contained in:
1 parent
7c2bf9bd17
commit
3553a9d617
2 files changed
+32
-20
No files matched your search
@@ -325,7 +325,7 @@ sections:
|
|||||||
it does. For example, using the current implementation of
|
it does. For example, using the current implementation of
|
||||||
jq, we would see that the expression:
|
jq, we would see that the expression:
|
||||||
|
|
||||||
`1E1234567890 | .`
|
1E1234567890 | .
|
||||||
|
|
||||||
produces `1.7976931348623157e+308` on at least one platform.
|
produces `1.7976931348623157e+308` on at least one platform.
|
||||||
This is because, in the process of parsing the number, this
|
This is because, in the process of parsing the number, this
|
||||||
@@ -384,13 +384,13 @@ sections:
|
|||||||
- title: "Object Identifier-Index: `.foo`, `.foo.bar`"
|
- title: "Object Identifier-Index: `.foo`, `.foo.bar`"
|
||||||
body: |
|
body: |
|
||||||
|
|
||||||
The simplest *useful* filter is `.foo`. When given a
|
The simplest *useful* filter has the form `.foo`. When given a
|
||||||
JSON object (aka dictionary or hash) as input, it produces
|
JSON object (aka dictionary or hash) as input, `.foo` produces
|
||||||
the value at the key "foo", or null if there's none present.
|
the value at the key "foo" if the key is present, or null otherwise.
|
||||||
|
|
||||||
A filter of the form `.foo.bar` is equivalent to `.foo|.bar`.
|
A filter of the form `.foo.bar` is equivalent to `.foo|.bar`.
|
||||||
|
|
||||||
This syntax only works for simple, identifier-like keys, that
|
The `.foo` syntax only works for simple, identifier-like keys, that
|
||||||
is, keys that are all made of alphanumeric characters and
|
is, keys that are all made of alphanumeric characters and
|
||||||
underscore, and which do not start with a digit.
|
underscore, and which do not start with a digit.
|
||||||
|
|
||||||
@@ -399,15 +399,17 @@ sections:
|
|||||||
`."foo$"`, or else `.["foo$"]`.
|
`."foo$"`, or else `.["foo$"]`.
|
||||||
|
|
||||||
For example `.["foo::bar"]` and `.["foo.bar"]` work while
|
For example `.["foo::bar"]` and `.["foo.bar"]` work while
|
||||||
`.foo::bar` does not, and `.foo.bar` means `.["foo"].["bar"]`.
|
`.foo::bar` does not.
|
||||||
|
|
||||||
examples:
|
examples:
|
||||||
- program: '.foo'
|
- program: '.foo'
|
||||||
input: '{"foo": 42, "bar": "less interesting data"}'
|
input: '{"foo": 42, "bar": "less interesting data"}'
|
||||||
output: [42]
|
output: [42]
|
||||||
|
|
||||||
- program: '.foo'
|
- program: '.foo'
|
||||||
input: '{"notfoo": true, "alsonotfoo": false}'
|
input: '{"notfoo": true, "alsonotfoo": false}'
|
||||||
output: ['null']
|
output: ['null']
|
||||||
|
|
||||||
- program: '.["foo"]'
|
- program: '.["foo"]'
|
||||||
input: '{"foo": 42}'
|
input: '{"foo": 42}'
|
||||||
output: [42]
|
output: [42]
|
||||||
@@ -967,13 +969,13 @@ sections:
|
|||||||
`map_values` when applied to arrays. These examples assume the
|
`map_values` when applied to arrays. These examples assume the
|
||||||
input is `[1]` in all cases:
|
input is `[1]` in all cases:
|
||||||
|
|
||||||
map(.+1) #=> [2]
|
map(.+1) #=> [2]
|
||||||
map(., .) #=> [1,1]
|
map(., .) #=> [1,1]
|
||||||
map(empty) #=> []
|
map(empty) #=> []
|
||||||
|
|
||||||
map_values(.+1) #=> [2]
|
map_values(.+1) #=> [2]
|
||||||
map_values(., .) #=> [1]
|
map_values(., .) #=> [1]
|
||||||
map_values(empty) #=> []
|
map_values(empty) #=> []
|
||||||
|
|
||||||
`map(f)` is equivalent to `[.[] | f]` and
|
`map(f)` is equivalent to `[.[] | f]` and
|
||||||
`map_values(f)` is equivalent to `.[] |= f`.
|
`map_values(f)` is equivalent to `.[] |= f`.
|
||||||
|
|||||||
Generated
+18
-8
@@ -258,7 +258,7 @@ Although the identity filter never modifies the value of its input, jq processin
|
|||||||
.
|
.
|
||||||
.nf
|
.nf
|
||||||
|
|
||||||
`1E1234567890 | \.`
|
1E1234567890 | \.
|
||||||
.
|
.
|
||||||
.fi
|
.fi
|
||||||
.
|
.
|
||||||
@@ -315,19 +315,19 @@ jq \'\. as $big | [$big, $big + 1] | map(\. > 10000000000000000000000000000000)\
|
|||||||
.IP "" 0
|
.IP "" 0
|
||||||
.
|
.
|
||||||
.SS "Object Identifier\-Index: \.foo, \.foo\.bar"
|
.SS "Object Identifier\-Index: \.foo, \.foo\.bar"
|
||||||
The simplest \fIuseful\fR filter is \fB\.foo\fR\. When given a JSON object (aka dictionary or hash) as input, it produces the value at the key "foo", or null if there\'s none present\.
|
The simplest \fIuseful\fR filter has the form \fB\.foo\fR\. When given a JSON object (aka dictionary or hash) as input, \fB\.foo\fR produces the value at the key "foo" if the key is present, or null otherwise\.
|
||||||
.
|
.
|
||||||
.P
|
.P
|
||||||
A filter of the form \fB\.foo\.bar\fR is equivalent to \fB\.foo|\.bar\fR\.
|
A filter of the form \fB\.foo\.bar\fR is equivalent to \fB\.foo|\.bar\fR\.
|
||||||
.
|
.
|
||||||
.P
|
.P
|
||||||
This syntax only works for simple, identifier\-like keys, that is, keys that are all made of alphanumeric characters and underscore, and which do not start with a digit\.
|
The \fB\.foo\fR syntax only works for simple, identifier\-like keys, that is, keys that are all made of alphanumeric characters and underscore, and which do not start with a digit\.
|
||||||
.
|
.
|
||||||
.P
|
.P
|
||||||
If the key contains special characters or starts with a digit, you need to surround it with double quotes like this: \fB\."foo$"\fR, or else \fB\.["foo$"]\fR\.
|
If the key contains special characters or starts with a digit, you need to surround it with double quotes like this: \fB\."foo$"\fR, or else \fB\.["foo$"]\fR\.
|
||||||
.
|
.
|
||||||
.P
|
.P
|
||||||
For example \fB\.["foo::bar"]\fR and \fB\.["foo\.bar"]\fR work while \fB\.foo::bar\fR does not, and \fB\.foo\.bar\fR means \fB\.["foo"]\.["bar"]\fR\.
|
For example \fB\.["foo::bar"]\fR and \fB\.["foo\.bar"]\fR work while \fB\.foo::bar\fR does not\.
|
||||||
.
|
.
|
||||||
.IP "" 4
|
.IP "" 4
|
||||||
.
|
.
|
||||||
@@ -960,11 +960,21 @@ Specifically, for object inputs, \fBmap_value(f)\fR constructs the output object
|
|||||||
.P
|
.P
|
||||||
Here are some examples to clarify the behavior of \fBmap\fR and \fBmap_values\fR when applied to arrays\. These examples assume the input is \fB[1]\fR in all cases:
|
Here are some examples to clarify the behavior of \fBmap\fR and \fBmap_values\fR when applied to arrays\. These examples assume the input is \fB[1]\fR in all cases:
|
||||||
.
|
.
|
||||||
.P
|
.IP "" 4
|
||||||
map(\.+1) #=> [2] map(\., \.) #=> [1,1] map(empty) #=> []
|
|
||||||
.
|
.
|
||||||
.P
|
.nf
|
||||||
map_values(\.+1) #=> [2] map_values(\., \.) #=> [1] map_values(empty) #=> []
|
|
||||||
|
map(\.+1) #=> [2]
|
||||||
|
map(\., \.) #=> [1,1]
|
||||||
|
map(empty) #=> []
|
||||||
|
|
||||||
|
map_values(\.+1) #=> [2]
|
||||||
|
map_values(\., \.) #=> [1]
|
||||||
|
map_values(empty) #=> []
|
||||||
|
.
|
||||||
|
.fi
|
||||||
|
.
|
||||||
|
.IP "" 0
|
||||||
.
|
.
|
||||||
.P
|
.P
|
||||||
\fBmap(f)\fR is equivalent to \fB[\.[] | f]\fR and \fBmap_values(f)\fR is equivalent to \fB\.[] |= f\fR\.
|
\fBmap(f)\fR is equivalent to \fB[\.[] | f]\fR and \fBmap_values(f)\fR is equivalent to \fB\.[] |= f\fR\.
|
||||||
|
|||||||
Reference in new issue
Block a user