From 32bf2f03e6828f5d285a1b88514f47d86a70fea8 Mon Sep 17 00:00:00 2001 From: Nicolas Williams Date: Sat, 16 Aug 2014 16:38:39 -0500 Subject: [PATCH] Update Debian status (fix #483) Thanks Simon! --- download/index.html | 2 +- index.html | 2 +- index/index.html | 2 +- manual/index.html | 783 +++++++++++++++++++++++++++++++++----------- sitemap.xml | 2 +- 5 files changed, 591 insertions(+), 200 deletions(-) diff --git a/download/index.html b/download/index.html index fd176842..8e4cd2ad 100644 --- a/download/index.html +++ b/download/index.html @@ -77,7 +77,7 @@
  • -

    jq 1.3 is in Debian (a request to update to 1.4 has been filed)

    +

    jq 1.4 is in Debian

  • diff --git a/index.html b/index.html index 3d4e370c..0c4dc920 100644 --- a/index.html +++ b/index.html @@ -58,7 +58,7 @@
    - Download jq-1.4 + Download jq-1.4-2-g15c4a7f-dirty
    - - - -
    -

    -

    unique_by

    - -

    -

    The unique_by(.foo) function takes as input an array and produces an array of the same elements, in sorted order, with elqements with a duplicate .foo field removed. Think of it as making an array by taking one element out of every group produced by group_by.

    - - -
    - - - - Examples - -
    - - - + @@ -2593,7 +2666,7 @@ map(foo) | from_entries, useful for doing some operation to all keys and
    jq 'unique_by(.foo)'
    jq 'unique(.foo)'
    Input[{"foo": 1, "bar": 2}, {"foo": 1, "bar": 3}, {"foo": 4, "bar": 5}]
    - + @@ -2622,11 +2695,11 @@ map(foo) | from_entries, useful for doing some operation to all keys and
    - + Example -
    +
    jq 'unique_by(length)'
    jq 'unique(length)'
    Input["chunky", "bacon", "kitten", "cicada", "asparagus"]
    @@ -2649,9 +2722,9 @@ map(foo) | from_entries, useful for doing some operation to all keys and -
    +

    -

    contains

    +

    contains(element)

    The filter contains(b) will produce true if b is completely contained within the input. A string B is contained in a string A if B is a substring of A. An array B is contained in an array A is all elements in B are contained in any element in A. An object B is contained in object A if all of the values in B are contained in the value in A with the same key. All other types are assumed to be contained in each other if they are equal.

    @@ -2659,11 +2732,11 @@ map(foo) | from_entries, useful for doing some operation to all keys and
    @@ -2756,11 +2829,11 @@ map(foo) | from_entries, useful for doing some operation to all keys and
    - + Examples -
    +
    @@ -2823,11 +2896,11 @@ map(foo) | from_entries, useful for doing some operation to all keys and
    - + Examples -
    +
    @@ -2865,9 +2938,9 @@ map(foo) | from_entries, useful for doing some operation to all keys and -
    +

    -

    startswith

    +

    startswith(str)

    Outputs true if . starts with the given string argument.

    @@ -2875,11 +2948,11 @@ map(foo) | from_entries, useful for doing some operation to all keys and
    @@ -2902,9 +2975,9 @@ map(foo) | from_entries, useful for doing some operation to all keys and -
    +

    -

    endswith

    +

    endswith(str)

    Outputs true if . ends with the given string argument.

    @@ -2912,11 +2985,11 @@ map(foo) | from_entries, useful for doing some operation to all keys and
    @@ -2939,9 +3012,245 @@ map(foo) | from_entries, useful for doing some operation to all keys and -
    +

    -

    ltrimstr

    +

    match(val), match(regex; modifiers)

    + +

    +

    The filter match(val) performs PCRE regex matching on its input. val can be either a string or an array. If it is an array, the first element is the regex specifier and the optional second element is the modifier flags. The accepted modifier flags are:

    + +
      +
    • g - Global search (find all matches, not just the first)
    • + +
    • i - Case insensitive search
    • + +
    • x - Extended regex format (ignore whitespaces)
    • + +
    • m - Multi line mode (’.’ will match newlines)
    • + +
    • s - Single line mode (’^’ -> ‘\A’, ’$’ -> ‘\Z’)
    • + +
    • p - Both s and m modes are enabled
    • + +
    • l - Find longest possible matches
    • + +
    • n - Ignore empty matches
    • +
    + +

    The filter outputs an object for each match it finds. Matches have the following fields:

    + +
      +
    • offset - offset in UTF-8 codepoints from the beginning of the input
    • + +
    • length - length in UTF-8 codepoints of the match
    • + +
    • string - the string that it matched
    • + +
    • captures - an array of objects representing capturing groups.
    • +
    + +

    Capturing group objects have the following fields:

    + +
      +
    • offset - offset in UTF-8 codepoints from the beginning of the input
    • + +
    • length - length in UTF-8 codepoints of this capturing group
    • + +
    • string - the string that was captured
    • + +
    • name - the name of the capturing group (or null if it was unnamed)
    • +
    + +

    Capturing groups that did not match anything return an offset of -1

    + + +
    + + + + Examples + +
    + + +
    + + + + + + + + + + + + + + + + + + + +
    jq 'match("(abc)+"; "g")'
    Input"abc abc"
    Output{"offset": 0, "length": 3, "string": "abc", "captures": [{"offset": 0, "length": 3, "string": "abc", "name": null}]}
    {"offset": 4, "length": 3, "string": "abc", "captures": [{"offset": 4, "length": 3, "string": "abc", "name": null}]}
    + + + + + + + + + + + + + + +
    jq 'match("foo")'
    Input"foo bar foo"
    Output{"offset": 0, "length": 3, "string": "foo", "captures": []}
    + + + + + + + + + + + + + + + + + + + + + +
    jq 'match(["foo", "ig"])'
    Input"foo bar FOO"
    Output{"offset": 0, "length": 3, "string": "foo", "captures": []}
    {"offset": 8, "length": 3, "string": "FOO", "captures": []}
    + + + + + + + + + + + + + + + + + + + + + +
    jq 'match("foo (?bar)? foo"; "ig")'
    Input"foo bar foo foo foo"
    Output{"offset": 0, "length": 11, "string": "foo bar foo", "captures": [{"offset": 4, "length": 3, "string": "bar", "name": "bar123"}]}
    {"offset": 12, "length": 8, "string": "foo foo", "captures": [{"offset": -1, "length": 0, "string": null, "name": "bar123"}]}
    + +
    +
    + +
    + +
    +

    +

    test(val), test(regex), test(regex; modifiers)

    + +

    +

    Like match, but does not return match objects, only true or false for whether or not the regex matches the input.

    + + +
    + + + + Examples + +
    + + + + + + + + + + + + + + + +
    jq 'test("foo")'
    Input"foo"
    Outputtrue
    + + + + + + + + + + + + + + +
    jq 'test("foo"; "i")'
    Input"Foo"
    Outputtrue
    + + + + + + + + + + + + + + +
    jq 'test("foo")'
    Input"bar"
    Outputfalse
    + +
    +
    + +
    + +
    +

    +

    sub(re; sub), gsub(re; sub)

    + +

    +

    sub(re; sub) replaces with sub the first match of the given regexp re in its input. gsub(re; sub) replaces all matches.

    + + +
    + +
    +

    +

    scan(re), split2(re)

    + +

    +

    scan(re) outputs the substrings of its input that match the given regexp re.

    + +

    split2(re) outputs the substrings of its input that don’t match the given regexp re. (Compare to split(sep), which outputs an array of substrings that don’t exactly match sep.)

    + + +
    + +
    +

    +

    ltrimstr(str)

    Outputs its input with the given prefix string removed, if it starts with it.

    @@ -2949,11 +3258,11 @@ map(foo) | from_entries, useful for doing some operation to all keys and
    - + Example -
    +
    @@ -2976,9 +3285,9 @@ map(foo) | from_entries, useful for doing some operation to all keys and -
    +

    -

    rtrimstr

    +

    rtrimstr(str)

    Outputs its input with the given suffix string removed, if it starts with it.

    @@ -2986,11 +3295,11 @@ map(foo) | from_entries, useful for doing some operation to all keys and
    @@ -3023,11 +3332,11 @@ map(foo) | from_entries, useful for doing some operation to all keys and
    @@ -3060,11 +3369,11 @@ map(foo) | from_entries, useful for doing some operation to all keys and
    @@ -3097,11 +3406,11 @@ map(foo) | from_entries, useful for doing some operation to all keys and
    @@ -3124,9 +3433,9 @@ map(foo) | from_entries, useful for doing some operation to all keys and -
    +

    -

    join

    +

    join(str)

    Joins the array of elements given as input, using the argument as separator. It is the inverse of split: that is, running split("foo") | join("foo") over any input string returns said input string.

    @@ -3134,11 +3443,11 @@ map(foo) | from_entries, useful for doing some operation to all keys and
    @@ -3161,12 +3470,12 @@ map(foo) | from_entries, useful for doing some operation to all keys and -
    +

    -

    recurse

    +

    recurse(f), recurse, recurse_down

    -

    The recurse function allows you to search through a recursive structure, and extract interesting data from all levels. Suppose your input represents a filesystem:

    +

    The recurse(f) function allows you to search through a recursive structure, and extract interesting data from all levels. Suppose your input represents a filesystem:

    {"name": "/", "children": [
       {"name": "/bin", "children": [
    @@ -3180,14 +3489,18 @@ map(foo) | from_entries, useful for doing some operation to all keys and
     
     
    recurse(.children[]) | .name
    +

    When called without an argument, recurse is equivalent to recurse(.[]?).

    + +

    For legacy reasons, recurse_down exists as an alias to calling recurse without arguments. This alias is considered deprecated and will be removed in the next major release.

    +
    @@ -3226,38 +3539,55 @@ map(foo) | from_entries, useful for doing some operation to all keys and
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    jq 'recurse'
    Input{"a":0,"b":[1]}
    Output0
    [1]
    1
    +
    -
    -

    -

    recurse_down

    - -

    -

    A quieter version of recurse(.[]), equivalent to:

    - -
    def recurse_down: recurse(.[]?);
    - - -
    -

    ..

    -

    Short-hand for recurse_down. This is intended to resemble the XPath // operator. Note that ..a does not work; use ..|a instead.

    +

    Short-hand for recurse without arguments. This is intended to resemble the XPath // operator. Note that ..a does not work; use ..|a instead. In the example below we use ..|.a? to find all the values of object keys “a” in any object found “below” ..

    - + Example -
    +
    @@ -3280,6 +3610,43 @@ map(foo) | from_entries, useful for doing some operation to all keys and +
    +

    +

    env

    + +

    +

    Outputs an object representing jq’s environment.

    + + +
    + + + + Example + +
    + + +
    + + + + + + + + + + + + +
    jq 'env.PAGER'
    Inputnull
    Output"less"
    + +
    +
    + +
    +

    String interpolation - \(foo)

    @@ -3290,11 +3657,11 @@ map(foo) | from_entries, useful for doing some operation to all keys and
    - + Example -
    +
    @@ -3327,11 +3694,11 @@ map(foo) | from_entries, useful for doing some operation to all keys and
    @@ -3448,11 +3815,11 @@ map(foo) | from_entries, useful for doing some operation to all keys and
    @@ -3508,11 +3875,11 @@ map(foo) | from_entries, useful for doing some operation to all keys and
    @@ -3573,11 +3940,11 @@ B end instead.

    @@ -3618,11 +3985,11 @@ end'
    @@ -3662,11 +4029,11 @@ not.

    @@ -3774,11 +4141,11 @@ not.

    @@ -3871,14 +4238,16 @@ not.

    won’t.

    +

    For programming language theorists, it’s more accurate to say that jq variables are lexically-scoped bindings. In particular there’s no way to change the value of a binding; one can only setup a new binding with the same name, but which will not be visible where the old one was.

    +
    @@ -3896,6 +4265,21 @@ not.

    + + + + + + + + + + + + + +
    jq '. as $i|[(.*2|. as $i| $i), $i]'
    Input5
    Output[10,5]
    +
    @@ -3914,7 +4298,12 @@ not.

    def map(f): [.[] | f];
    -

    Arguments are passed as filters, not as values. The same argument may be referenced multiple times with different inputs (here f is run for each element of the input array). Arguments to a function work more like callbacks than like value arguments.

    +

    Arguments are passed as filters, not as values. The same argument may be referenced multiple times with different inputs (here f is run for each element of the input array). Arguments to a function work more like callbacks than like value arguments. This is important to understand. Consider:

    + +
    def foo(f): f|f;
    +5|foo(.*2)
    + +

    The result will be 20 because f is .*2, and during the first invocation of f . will be 5, and the second time it will be 10 (5 * 2), so the result will be 20. Function arguments are filters, and filters expect an input when invoked.

    If you want the value-argument behaviour for defining simple functions, you can just use a variable:

    @@ -3922,14 +4311,16 @@ not.

    With that definition, addvalue(.foo) will add the current input’s .foo field to each element of the array.

    +

    Multiple definitions using the same function name are allowed. Each re-definition replaces the previous one for the same number of function arguments, but only for references from functions (or main program) subsequent to the re-definition.

    +
    - + Examples -
    +
    @@ -3978,18 +4369,18 @@ not.

    For each result that .[] produces, . + $item is run to accumulate a running total, starting from 0. In this example, .[] produces the results 3, 2, and 1, so the effect is similar to running something like this:

    -
    0 | (3 as $item | . + $item) | 
    +
    0 | (3 as $item | . + $item) |
         (2 as $item | . + $item) |
         (1 as $item | . + $item)
    @@ -4064,11 +4455,11 @@ not.

    @@ -4096,7 +4487,7 @@ not.

    Complex assignments

    -

    Lots more things are allowed on the left-hand side of a jq assignment than in most langauges. We’ve already seen simple field accesses on the left hand side, and it’s no surprise that array accesses work just as well:

    +

    Lots more things are allowed on the left-hand side of a jq assignment than in most languages. We’ve already seen simple field accesses on the left hand side, and it’s no surprise that array accesses work just as well:

    .posts[0].title = "JQ Manual"
    diff --git a/sitemap.xml b/sitemap.xml index 111e7b73..413a44fe 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -17,7 +17,7 @@ http://stedolan.github.io/jq/manual/ - 2014-06-16 + 2014-06-24 monthly