@@ -97,9 +97,9 @@ sections:
9797 program and backslash-escaped double-quotes (`\"`) inside the jq
9898 program.
9999
100- Unix shells: `jq '.["foo"]'`
101- Powershell: `jq '.[\"foo\"]'`
102- Windows command shell: `jq ".[\"foo\"]"`
100+ * Unix shells: `jq '.["foo"]'`
101+ * Powershell: `jq '.[\"foo\"]'`
102+ * Windows command shell: `jq ".[\"foo\"]"`
103103
104104 You can affect how jq reads and writes its input and output
105105 using some command-line options:
@@ -284,7 +284,7 @@ sections:
284284
285285 Remaining arguments are positional JSON text arguments. These
286286 are available to the jq program as `$ARGS.positional[]`.
287-
287+
288288 * `--`:
289289
290290 Terminates argument processing. Remaining arguments are
@@ -318,19 +318,19 @@ sections:
318318 program can be a useful way of formatting JSON output from,
319319 say, `curl`.
320320
321- An important point about the identity filter is that it
322- guarantees to preserve the literal decimal representation
323- of values. This is particularly important when dealing with numbers
324- which can't be losslessly converted to an IEEE754 double precision
321+ An important point about the identity filter is that it
322+ guarantees to preserve the literal decimal representation
323+ of values. This is particularly important when dealing with numbers
324+ which can't be losslessly converted to an IEEE754 double precision
325325 representation.
326326
327327 jq doesn't truncate the literal numbers to double unless there
328328 is a need to make arithmetic operations with the number.
329- Comparisons are carried out over the untruncated big decimal
329+ Comparisons are carried out over the untruncated big decimal
330330 representation of the number.
331331
332332 jq will also try to maintain the original decimal precision of the provided
333- number literal. See below for examples.
333+ number literal. See below for examples.
334334
335335 examples :
336336 - program : ' .'
@@ -400,17 +400,17 @@ sections:
400400 input : ' [1,2]'
401401 output : ['[]']
402402
403- - title : " Generic Object Index: `.[<string>]`"
403+ - title : " Object Index: `.[<string>]`"
404404 body : |
405405
406406 You can also look up fields of an object using syntax like
407- `.["foo"]` (.foo above is a shorthand version of this, but
407+ `.["foo"]` (` .foo` above is a shorthand version of this, but
408408 only for identifier-like strings).
409409
410- - title : " Array Index: `.[2 ]`"
410+ - title : " Array Index: `.[<number> ]`"
411411 body : |
412412
413- When the index value is an integer, `.[<value >]` can index
413+ When the index value is an integer, `.[<number >]` can index
414414 arrays. Arrays are zero-based, so `.[2]` returns the third
415415 element.
416416
@@ -430,16 +430,16 @@ sections:
430430 input : ' [1,2,3]'
431431 output : ['2']
432432
433- - title : " Array/String Slice: `.[10:15 ]`"
433+ - title : " Array/String Slice: `.[<number>:<number> ]`"
434434 body : |
435435
436- The `.[10:15 ]` syntax can be used to return a subarray of an
437- array or substring of a string. The array returned by
438- `.[10:15]` will be of length 5, containing the elements from
439- index 10 (inclusive) to index 15 (exclusive). Either index may
440- be negative (in which case it counts backwards from the end of
441- the array), or omitted (in which case it refers to the start
442- or end of the array).
436+ The `.[<number>:<number> ]` syntax can be used to return a
437+ subarray of an array or substring of a string. The array
438+ returned by `.[10:15]` will be of length 5, containing the
439+ elements from index 10 (inclusive) to index 15 (exclusive).
440+ Either index may be negative (in which case it counts
441+ backwards from the end of the array), or omitted (in which
442+ case it refers to the start or end of the array).
443443
444444 examples :
445445 - program : ' .[2:4]'
@@ -564,15 +564,15 @@ sections:
564564 expression that takes an input, ignores it, and returns 42
565565 instead.
566566
567- Numbers in jq are internally represented by their IEEE754 double
568- precision approximation. Any arithmetic operation with numbers,
569- whether they are literals or results of previous filters, will
567+ Numbers in jq are internally represented by their IEEE754 double
568+ precision approximation. Any arithmetic operation with numbers,
569+ whether they are literals or results of previous filters, will
570570 produce a double precision floating point result.
571571
572572 However, when parsing a literal jq will store the original literal
573573 string. If no mutation is applied to this value then it will make
574- to the output in its original form, even if conversion to double
575- would result in a loss.
574+ to the output in its original form, even if conversion to double
575+ would result in a loss.
576576
577577 entries :
578578 - title : " Array construction: `[]`"
@@ -699,21 +699,21 @@ sections:
699699 - title : Builtin operators and functions
700700 body : |
701701
702- Some jq operator (for instance, `+`) do different things
702+ Some jq operators (for instance, `+`) do different things
703703 depending on the type of their arguments (arrays, numbers,
704704 etc.). However, jq never does implicit type conversions. If you
705705 try to add a string to an object you'll get an error message and
706706 no result.
707707
708- Please note that all numbers are converted to IEEE754 double precision
708+ Please note that all numbers are converted to IEEE754 double precision
709709 floating point representation. Arithmetic and logical operators are working
710- with these converted doubles. Results of all such operations are also limited
711- to the double precision.
710+ with these converted doubles. Results of all such operations are also limited
711+ to the double precision.
712712
713- The only exception to this behaviour of number is a snapshot of original number
713+ The only exception to this behaviour of number is a snapshot of original number
714714 literal. When a number which originally was provided as a literal is never
715- mutated until the end of the program then it is printed to the output in its
716- original literal form. This also includes cases when the original literal
715+ mutated until the end of the program then it is printed to the output in its
716+ original literal form. This also includes cases when the original literal
717717 would be truncated when converted to the IEEE754 double precision floating point
718718 number.
719719
@@ -772,7 +772,7 @@ sections:
772772 input : ' ["xml", "yaml", "json"]'
773773 output : ['["json"]']
774774
775- - title : " Multiplication, division, modulo: `*`, `/`, and `%`"
775+ - title : " Multiplication, division, modulo: `*`, `/`, `%`"
776776 body : |
777777
778778 These infix operators behave as expected when given two numbers.
@@ -903,18 +903,18 @@ sections:
903903 input : ' [2, 0]'
904904 output : ['[false, true]']
905905
906- - title : " `map(x )`, `map_values(x )`"
906+ - title : " `map(f )`, `map_values(f )`"
907907 body : |
908908
909- For any filter `x `, `map(x )` will run that filter for each
909+ For any filter `f `, `map(f )` will run that filter for each
910910 element of the input array, and return the outputs in a new
911911 array. `map(.+1)` will increment each element of an array of numbers.
912912
913- Similarly, `map_values(x )` will run that filter for each element,
913+ Similarly, `map_values(f )` will run that filter for each element,
914914 but it will return an object when an object is passed.
915915
916- `map(x )` is equivalent to `[.[] | x ]`. In fact, this is how
917- it's defined. Similarly, `map_values(x )` is defined as `.[] |= x `.
916+ `map(f )` is equivalent to `[.[] | f ]`. In fact, this is how
917+ it's defined. Similarly, `map_values(f )` is defined as `.[] |= f `.
918918
919919 examples :
920920 - program : ' map(.+1)'
@@ -1013,19 +1013,19 @@ sections:
10131013 input : ' {"a":{"b":1},"x":{"y":2}}'
10141014 output : ['{"a":{},"x":{"y":2}}']
10151015
1016- - title : " `to_entries`, `from_entries`, `with_entries`"
1016+ - title : " `to_entries`, `from_entries`, `with_entries(f) `"
10171017 body : |
10181018
10191019 These functions convert between an object and an array of
10201020 key-value pairs. If `to_entries` is passed an object, then
10211021 for each `k: v` entry in the input, the output array
10221022 includes `{"key": k, "value": v}`.
10231023
1024- `from_entries` does the opposite conversion, and
1025- `with_entries(foo)` is a shorthand for `to_entries |
1026- map(foo) | from_entries`, useful for doing some operation to
1027- all keys and values of an object. `from_entries` accepts key, Key,
1028- name, Name, value and Value as keys.
1024+ `from_entries` does the opposite conversion, and `with_entries(f)`
1025+ is a shorthand for `to_entries | map(f) | from_entries`, useful for
1026+ doing some operation to all keys and values of an object.
1027+ `from_entries` accepts `" key"`, `" Key"`, `"name"`, `"Name"` ,
1028+ `"value"`, and `" Value"` as keys.
10291029
10301030 examples :
10311031 - program : ' to_entries'
@@ -1042,8 +1042,8 @@ sections:
10421042 - title : " `select(boolean_expression)`"
10431043 body : |
10441044
1045- The function `select(foo )` produces its input unchanged if
1046- `foo ` returns true for that input, and produces no output
1045+ The function `select(f )` produces its input unchanged if
1046+ `f ` returns true for that input, and produces no output
10471047 otherwise.
10481048
10491049 It's useful for filtering lists: `[1,2,3] | map(select(. >= 2))`
@@ -1244,12 +1244,12 @@ sections:
12441244 input : ' [{"foo": "bar"}, [{"foo": "baz"}]]'
12451245 output : ['[{"foo": "bar"}, {"foo": "baz"}]']
12461246
1247- - title : " `range(upto)`, `range(from;upto)`, `range(from;upto;by)`"
1247+ - title : " `range(upto)`, `range(from; upto)`, `range(from; upto; by)`"
12481248 body : |
12491249
1250- The `range` function produces a range of numbers. `range(4;10)`
1250+ The `range` function produces a range of numbers. `range(4; 10)`
12511251 produces 6 numbers, from 4 (inclusive) to 10 (exclusive). The numbers
1252- are produced as separate outputs. Use `[range(4;10)]` to get a range as
1252+ are produced as separate outputs. Use `[range(4; 10)]` to get a range as
12531253 an array.
12541254
12551255 The one argument form generates numbers from 0 to the given
@@ -1262,22 +1262,22 @@ sections:
12621262 with an increment of `by`.
12631263
12641264 examples :
1265- - program : ' range(2;4)'
1265+ - program : ' range(2; 4)'
12661266 input : ' null'
12671267 output : ['2', '3']
1268- - program : ' [range(2;4)]'
1268+ - program : ' [range(2; 4)]'
12691269 input : ' null'
12701270 output : ['[2,3]']
12711271 - program : ' [range(4)]'
12721272 input : ' null'
12731273 output : ['[0,1,2,3]']
1274- - program : ' [range(0;10;3)]'
1274+ - program : ' [range(0; 10; 3)]'
12751275 input : ' null'
12761276 output : ['[0,3,6,9]']
1277- - program : ' [range(0;10;-1)]'
1277+ - program : ' [range(0; 10; -1)]'
12781278 input : ' null'
12791279 output : ['[]']
1280- - program : ' [range(0;-5;-1)]'
1280+ - program : ' [range(0; -5; -1)]'
12811281 input : ' null'
12821282 output : ['[0,-1,-2,-3,-4]']
12831283
@@ -1383,8 +1383,8 @@ sections:
13831383 `sort` may be used to sort by a particular field of an
13841384 object, or by applying any jq filter.
13851385
1386- `sort_by(foo )` compares two elements by comparing the result of
1387- `foo ` on each element.
1386+ `sort_by(f )` compares two elements by comparing the result of
1387+ `f ` on each element.
13881388
13891389 examples :
13901390 - program : ' sort'
@@ -1866,7 +1866,7 @@ sections:
18661866 input : ' [1,2,3]'
18671867 output : ['[1,2,3,4]']
18681868
1869- - title : " String interpolation - `\\ (foo )`"
1869+ - title : " String interpolation: `\\ (exp )`"
18701870 body : |
18711871
18721872 Inside a string, you can put an expression inside parens
@@ -1976,10 +1976,6 @@ sections:
19761976 input : ' "This works if x < y"'
19771977 output : ['"This works if x < y"']
19781978
1979- # - program: '@html "<span>Anonymous said: \(.)</span>"'
1980- # input: '"<script>alert(\"lol hax\");</script>"'
1981- # output: ["<span>Anonymous said: <script>alert("lol hax");</script></span>"]
1982-
19831979 - program : ' @sh "echo \(.)"'
19841980 input : " \" O'Hara's Ale\" "
19851981 output : ["\"echo 'O'\\\\''Hara'\\\\''s Ale'\""]
@@ -2134,7 +2130,7 @@ sections:
21342130 input : ' [1, 1.0, "1", "banana"]'
21352131 output : ['true', 'true', 'false', 'false']
21362132
2137- - title : if-then-else
2133+ - title : if-then-else-end
21382134 body : |
21392135
21402136 `if A then B else C end` will act the same as `B` if `A`
@@ -2159,17 +2155,18 @@ sections:
21592155 More cases can be added to an if using `elif A then B` syntax.
21602156
21612157 examples :
2162- - program : ' if . == 0 then
2158+ - program : |-
2159+ if . == 0 then
21632160 "zero"
21642161 elif . == 1 then
21652162 "one"
21662163 else
21672164 "many"
2168- end'
2165+ end
21692166 input: 2
21702167 output: ['"many"']
21712168
2172- - title : " `>, >=, <=, <`"
2169+ - title : " `>`, `>=`, `<=`, ` <`"
21732170 body : |
21742171
21752172 The comparison operators `>`, `>=`, `<=`, `<` return whether
@@ -2184,12 +2181,13 @@ sections:
21842181 input : 2
21852182 output : ['true']
21862183
2187- - title : and/or/ not
2184+ - title : " ` and`, `or`, ` not` "
21882185 body : |
21892186
2190- jq supports the normal Boolean operators and/or/not. They have the
2191- same standard of truth as if expressions - false and null are
2192- considered "false values", and anything else is a "true value".
2187+ jq supports the normal Boolean operators `and`, `or`, `not`.
2188+ They have the same standard of truth as if expressions -
2189+ `false` and `null` are considered "false values", and
2190+ anything else is a "true value".
21932191
21942192 If an operand of one of these operators produces multiple
21952193 results, the operator itself will produce a result for each input.
@@ -2199,12 +2197,12 @@ sections:
21992197 rather than with special syntax, as in `.foo and .bar |
22002198 not`.
22012199
2202- These three only produce the values " true" and " false" , and
2200+ These three only produce the values ` true` and ` false` , and
22032201 so are only useful for genuine Boolean operations, rather
22042202 than the common Perl/Python/Ruby idiom of
22052203 "value_that_may_be_null or default". If you want to use this
22062204 form of "or", picking between two values rather than
2207- evaluating a condition, see the "//" operator below.
2205+ evaluating a condition, see the `//` operator below.
22082206
22092207 examples :
22102208 - program : ' 42 and "a string"'
@@ -2213,9 +2211,6 @@ sections:
22132211 - program : ' (true, false) or false'
22142212 input : ' null'
22152213 output : ['true', 'false']
2216- # - program: '(true, false) and (true, false)'
2217- # input: 'null'
2218- # output: ['true', 'false', 'false', 'false']
22192214 - program : ' (true, true) and (true, false)'
22202215 input : ' null'
22212216 output : ['true', 'false', 'true', 'false']
@@ -2568,15 +2563,15 @@ sections:
25682563 fields, and another object which is used to map author usernames to
25692564 real names. Our input looks like:
25702565
2571- {"posts": [{"title": "Frist psot ", "author": "anon"},
2566+ {"posts": [{"title": "First post ", "author": "anon"},
25722567 {"title": "A well-written article", "author": "person1"}],
25732568 "realnames": {"anon": "Anonymous Coward",
25742569 "person1": "Person McPherson"}}
25752570
25762571 We want to produce the posts with the author field containing a real
25772572 name, as in:
25782573
2579- {"title": "Frist psot ", "author": "Anonymous Coward"}
2574+ {"title": "First post ", "author": "Anonymous Coward"}
25802575 {"title": "A well-written article", "author": "Person McPherson"}
25812576
25822577 We use a variable, $names, to store the realnames object, so that we
@@ -2590,7 +2585,7 @@ sections:
25902585 foreach loop.
25912586
25922587 Just as `{foo}` is a handy way of writing `{foo: .foo}`, so
2593- `{$foo}` is a handy way of writing `{foo:$foo}`.
2588+ `{$foo}` is a handy way of writing `{foo: $foo}`.
25942589
25952590 Multiple variables may be declared using a single `as` expression by
25962591 providing a pattern that matches the structure of the input
0 commit comments