summaryrefslogtreecommitdiffstats
path: root/docs/content/manual/v1.3/manual.yml
diff options
context:
space:
mode:
Diffstat (limited to 'docs/content/manual/v1.3/manual.yml')
-rw-r--r--docs/content/manual/v1.3/manual.yml63
1 files changed, 29 insertions, 34 deletions
diff --git a/docs/content/manual/v1.3/manual.yml b/docs/content/manual/v1.3/manual.yml
index 95c759d4..34ddcf72 100644
--- a/docs/content/manual/v1.3/manual.yml
+++ b/docs/content/manual/v1.3/manual.yml
@@ -171,7 +171,7 @@ sections:
body: |
You can also look up fields of an object using syntax like
- `.["foo"]` (.foo above is a shorthand version of this). This
+ `.["foo"]` (`.foo` above is a shorthand version of this). This
one works for arrays as well, if the key is an
integer. Arrays are zero-based (like javascript), so `.[2]`
returns the third element of the array.
@@ -285,7 +285,7 @@ sections:
instead.
entries:
- - title: Array construction - `[]`
+ - title: "Array construction: `[]`"
body: |
As in JSON, `[]` is used to construct arrays, as in
@@ -310,7 +310,7 @@ sections:
- program: "[.user, .projects[]]"
input: '{"user":"stedolan", "projects": ["jq", "wikiflow"]}'
output: ['["stedolan", "jq", "wikiflow"]']
- - title: Objects - `{}`
+ - title: "Objects: `{}`"
body: |
Like JSON, `{}` is for constructing objects (aka
@@ -371,14 +371,14 @@ sections:
- title: Builtin operators and functions
body: |
- Some jq operator (for instance, `+`) do different things
+ Some jq operators (for instance, `+`) do different things
depending on the type of their arguments (arrays, numbers,
etc.). However, jq never does implicit type conversions. If you
try to add a string to an object you'll get an error message and
no result.
entries:
- - title: Addition - `+`
+ - title: "Addition: `+`"
body: |
The operator `+` takes two filters, applies them both
@@ -416,7 +416,7 @@ sections:
input: 'null'
output: ['{"a": 42, "b": 2, "c": 3}']
- - title: Subtraction - `-`
+ - title: "Subtraction: `-`"
body: |
As well as normal arithmetic subtraction on numbers, the `-`
@@ -431,7 +431,7 @@ sections:
input: '["xml", "yaml", "json"]'
output: ['["json"]']
- - title: Multiplication, division - `*` and `/`
+ - title: "Multiplication, division: `*` and `/`"
body: |
These operators only work on numbers, and do the expected.
@@ -504,7 +504,7 @@ sections:
input: '[[0,1], ["a","b","c"]]'
output: ['[false, true]']
- - title: '`to_entries`, `from_entries`, `with_entries`'
+ - title: "`to_entries`, `from_entries`, `with_entries(f)`"
body: |
These functions convert between an object and an array of
@@ -513,9 +513,9 @@ sections:
includes `{"key": k, "value": v}`.
`from_entries` does the opposite conversion, and
- `with_entries(foo)` is a shorthand for `to_entries |
- map(foo) | from_entries`, useful for doing some operation to
- all keys and values of an object.
+ `with_entries(f)` is a shorthand for `to_entries | map(f) |
+ from_entries`, useful for doing some operation to all keys
+ and values of an object.
examples:
- program: 'to_entries'
@@ -559,14 +559,14 @@ sections:
input: 'null'
output: ['[1,2,3]']
- - title: '`map(x)`'
+ - title: '`map(f)`'
body: |
- For any filter `x`, `map(x)` will run that filter for each
+ For any filter `f`, `map(f)` will run that filter for each
element of the input array, and produce the outputs a new
array. `map(.+1)` will increment each element of an array of numbers.
- `map(x)` is equivalent to `[.[] | x]`. In fact, this is how
+ `map(f)` is equivalent to `[.[] | f]`. In fact, this is how
it's defined.
examples:
@@ -648,7 +648,7 @@ sections:
input: '[0, false, [], {}, null, "hello"]'
output: ['["number", "boolean", "array", "object", "null", "string"]']
- - title: '`sort, sort_by`'
+ - title: '`sort`, `sort_by`'
body: |
The `sort` functions sorts its input, which must be an
@@ -796,7 +796,7 @@ sections:
- '{"foo":[]}'
- - title: String interpolation - `\(foo)`
+ - title: "String interpolation: `\\(exp)`"
body: |
Inside a string, you can put an expression inside parens
@@ -872,10 +872,6 @@ sections:
input: '"This works if x < y"'
output: ['"This works if x &lt; y"']
-# - program: '@html "<span>Anonymous said: \(.)</span>"'
-# input: '"<script>alert(\"lol hax\");</script>"'
-# output: ["<span>Anonymous said: &lt;script&gt;alert(&quot;lol hax&quot;);&lt;/script&gt;</span>"]
-
- program: '@sh "echo \(.)"'
input: "\"O'Hara's Ale\""
output: ["\"echo 'O'\\\\''Hara'\\\\''s Ale'\""]
@@ -898,7 +894,8 @@ sections:
- program: '.[] == 1'
input: '[1, 1.0, "1", "banana"]'
output: ['true', 'true', 'false', 'false']
- - title: if-then-else
+
+ - title: if-then-else-end
body: |
`if A then B else C end` will act the same as `B` if `A`
@@ -931,7 +928,7 @@ sections:
input: 2
output: ['"many"']
- - title: '`>, >=, <=, <`'
+ - title: "`>`, `>=`, `<=`, `<`"
body: |
The comparison operators `>`, `>=`, `<=`, `<` return whether
@@ -946,12 +943,13 @@ sections:
input: 2
output: ['true']
- - title: and/or/not
+ - title: "`and`, `or`, `not`"
body: |
- jq supports the normal Boolean operators and/or/not. They have the
- same standard of truth as if expressions - false and null are
- considered "false values", and anything else is a "true value".
+ jq supports the normal Boolean operators `and`, `or`, `not`.
+ They have the same standard of truth as if expressions -
+ `false` and `null` are considered "false values", and
+ anything else is a "true value".
If an operand of one of these operators produces multiple
results, the operator itself will produce a result for each input.
@@ -961,12 +959,12 @@ sections:
rather than with special syntax, as in `.foo and .bar |
not`.
- These three only produce the values "true" and "false", and
+ These three only produce the values `true` and `false`, and
so are only useful for genuine Boolean operations, rather
than the common Perl/Python/Ruby idiom of
"value_that_may_be_null or default". If you want to use this
form of "or", picking between two values rather than
- evaluating a condition, see the "//" operator below.
+ evaluating a condition, see the `//` operator below.
examples:
- program: '42 and "a string"'
@@ -975,9 +973,6 @@ sections:
- program: '(true, false) or false'
input: 'null'
output: ['true', 'false']
-# - program: '(true, false) and (true, false)'
-# input: 'null'
-# output: ['true', 'false', 'false', 'false']
- program: '(true, true) and (true, false)'
input: 'null'
output: ['true', 'false', 'true', 'false']
@@ -985,7 +980,7 @@ sections:
input: 'null'
output: ['[false, true]']
- - title: Alternative operator - `//`
+ - title: "Alternative operator: `//`"
body: |
A filter of the form `a // b` produces the same
@@ -1061,7 +1056,7 @@ sections:
fields, and another object which is used to map author usernames to
real names. Our input looks like:
- {"posts": [{"title": "Frist psot", "author": "anon"},
+ {"posts": [{"title": "First post", "author": "anon"},
{"title": "A well-written article", "author": "person1"}],
"realnames": {"anon": "Anonymous Coward",
"person1": "Person McPherson"}}
@@ -1069,7 +1064,7 @@ sections:
We want to produce the posts with the author field containing a real
name, as in:
- {"title": "Frist psot", "author": "Anonymous Coward"}
+ {"title": "First post", "author": "Anonymous Coward"}
{"title": "A well-written article", "author": "Person McPherson"}
We use a variable, $names, to store the realnames object, so that we