Skip to content
Myr

Update jq.1.prebuilt

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Nicolas Williams · committed by Nicolas Williams · parent 3df8f90 · Browse files · 1 file+231 added−120 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+231 added−120 removed

  • other:+231 added−120 removed

1 file+231 added−120 removed

modified:jq.1.prebuilt+231 added-120 removed
1.2.TH "JQ" "1" "May 2023" "" ""2.TH "JQ" "1" "July 2023" "" ""3.4.SH "NAME"5\fBjq\fR \- Command\-line JSON processor6.
27 unmodified lines
34.SH "INVOKING JQ"35jq filters run on a stream of JSON data\. The input to jq is parsed as a sequence of whitespace\-separated JSON values which are passed through the provided filter one at a time\. The output(s) of the filter are written to standard out, again as a sequence of whitespace\-separated JSON data\.36.37.P38Note: it is important to mind the shell\'s quoting rules\. As a general rule it\'s best to always quote (with single\-quote characters) the jq program, as too many characters with special meaning to jq are also shell meta\-characters\. For example, \fBjq "foo"\fR will fail on most Unix shells because that will be the same as \fBjq foo\fR, which will generally fail because \fBfoo is not defined\fR\. When using the Windows command shell (cmd\.exe) it\'s best to use double quotes around your jq program when given on the command\-line (instead of the \fB\-f program\-file\fR option), but then double\-quotes in the jq program need backslash escaping\.38Note: it is important to mind the shell\'s quoting rules\. As a general rule it\'s best to always quote (with single\-quote characters) the jq program, as too many characters with special meaning to jq are also shell meta\-characters\. For example, \fBjq "foo"\fR will fail on most Unix shells because that will be the same as \fBjq foo\fR, which will generally fail because \fBfoo is not defined\fR\. When using the Windows command shell (cmd\.exe) it\'s best to use double quotes around your jq program when given on the command\-line (instead of the \fB\-f program\-file\fR option), but then double\-quotes in the jq program need backslash escaping\. When using the Powershell (\fBpowershell\.exe\fR) or the Powershell Core (\fBpwsh\fR/\fBpwsh\.exe\fR), use single\-quote characters around the jq program and backslash\-escaped double\-quotes (\fB\e"\fR) inside the jq program\.39.40.IP "\(bu" 441Unix shells: \fBjq \'\.["foo"]\'\fR42.43.IP "\(bu" 444Powershell: \fBjq \'\.[\e"foo\e"]\'\fR45.46.IP "\(bu" 447Windows command shell: \fBjq "\.[\e"foo\e"]"\fR48.49.IP "" 050.51.P52You can affect how jq reads and writes its input and output using some command\-line options:53.54.TP
119 unmodified lines
174.TP175\fB\-e\fR / \fB\-\-exit\-status\fR:176.177.IP167Sets the exit status of jq to 0 if the last output values was neither \fBfalse\fR nor \fBnull\fR, 1 if the last output value was either \fBfalse\fR or \fBnull\fR, or 4 if no valid result was ever produced\. Normally jq exits with 2 if there was any usage problem or system error, 3 if there was a jq program compile error, or 0 if the jq program ran\.178Sets the exit status of jq to 0 if the last output value was neither \fBfalse\fR nor \fBnull\fR, 1 if the last output value was either \fBfalse\fR or \fBnull\fR, or 4 if no valid result was ever produced\. Normally jq exits with 2 if there was any usage problem or system error, 3 if there was a jq program compile error, or 0 if the jq program ran\.179.180.IP181Another way to set the exit status is with the \fBhalt_error\fR builtin function\.182.
45 unmodified lines
228.IP229Remaining arguments are positional JSON text arguments\. These are available to the jq program as \fB$ARGS\.positional[]\fR\.230.231.TP232\fB\-\-\fR:233.234.IP235Terminates argument processing\. Remaining arguments are positional, either strings, JSON texts, or input filenames, according to whether \fB\-\-args\fR or \fB\-\-jsonargs\fR were given\.236.237.TP238\fB\-\-run\-tests [filename]\fR:239.240.IP241Runs the tests in the given file or standard input\. This must be the last option given and does not honor all preceding options\. The input consists of comment lines, empty lines, and program lines followed by one input line, as many lines of output as are expected (one per output), and a terminating empty line\. Compilation failure tests start with a line containing only "%%FAIL", then a line containing the program to compile, then a line containing an error message to compare to the actual\.
9 unmodified lines
251.P252Since jq by default pretty\-prints all output, this trivial program can be a useful way of formatting JSON output from, say, \fBcurl\fR\.253.254.P238An important point about the identity filter is that it guarantees to preserve the literal decimal representation of values\. This is particularly important when dealing with numbers which can\'t be losslessly converted to an IEEE754 double precision representation\.255An important point about the identity filter is that it guarantees to preserve the literal decimal representation of values\. This is particularly important when dealing with numbers which can\'t be losslessly converted to an IEEE754 double precision representation\.256.257.P241jq doesn\'t truncate the literal numbers to double unless there is a need to make arithmetic operations with the number\. Comparisons are carried out over the untruncated big decimal representation of the number\.258jq doesn\'t truncate the literal numbers to double unless there is a need to make arithmetic operations with the number\. Comparisons are carried out over the untruncated big decimal representation of the number\.259.260.P244jq will also try to maintain the original decimal precision of the provided number literal\. See below for examples\. 261jq will also try to maintain the original decimal precision of the provided number literal\. See below for examples\.262.263.IP "" 4264.265.nf
53 unmodified lines
319.320.IP "" 0321.322.SS "Optional Object Identifier\-Index: \.foo?"306Just like \fB\.foo\fR, but does not output even an error when \fB\.\fR is not an array or an object\.323Just like \fB\.foo\fR, but does not output an error when \fB\.\fR is not an object\.324.325.IP "" 4326.327.nf
17 unmodified lines
345.fi346.347.IP "" 0348.332.SS "Generic Object Index: \.[<string>]"333You can also look up fields of an object using syntax like \fB\.["foo"]\fR (\.foo above is a shorthand version of this, but only for identifier\-like strings)\.349.SS "Object Index: \.[<string>]"350You can also look up fields of an object using syntax like \fB\.["foo"]\fR (\fB\.foo\fR above is a shorthand version of this, but only for identifier\-like strings)\.351.335.SS "Array Index: \.[2]"336When the index value is an integer, \fB\.[<value>]\fR can index arrays\. Arrays are zero\-based, so \fB\.[2]\fR returns the third element\.352.SS "Array Index: \.[<number>]"353When the index value is an integer, \fB\.[<number>]\fR can index arrays\. Arrays are zero\-based, so \fB\.[2]\fR returns the third element\.354.355.P356Negative indices are allowed, with \-1 referring to the last element, \-2 referring to the next to last element, and so on\.357.
16 unmodified lines
374.fi375.376.IP "" 0377.361.SS "Array/String Slice: \.[10:15]"362The \fB\.[10:15]\fR syntax can be used to return a subarray of an array or substring of a string\. The array returned by \fB\.[10:15]\fR will be of length 5, containing the elements from index 10 (inclusive) to index 15 (exclusive)\. Either index may be negative (in which case it counts backwards from the end of the array), or omitted (in which case it refers to the start or end of the array)\.378.SS "Array/String Slice: \.[<number>:<number>]"379The \fB\.[<number>:<number>]\fR syntax can be used to return a subarray of an array or substring of a string\. The array returned by \fB\.[10:15]\fR will be of length 5, containing the elements from index 10 (inclusive) to index 15 (exclusive)\. Either index may be negative (in which case it counts backwards from the end of the array), or omitted (in which case it refers to the start or end of the array)\.380.381.IP "" 4382.383.nf
112 unmodified lines
496.SH "TYPES AND VALUES"497jq supports the same set of datatypes as JSON \- numbers, strings, booleans, arrays, objects (which in JSON\-speak are hashes with only string keys), and "null"\.498.499.P483Booleans, null, strings and numbers are written the same way as in javascript\. Just like everything else in jq, these simple values take an input and produce an output \- \fB42\fR is a valid jq expression that takes an input, ignores it, and returns 42 instead\.500Booleans, null, strings and numbers are written the same way as in JSON\. Just like everything else in jq, these simple values take an input and produce an output \- \fB42\fR is a valid jq expression that takes an input, ignores it, and returns 42 instead\.501.502.P486Numbers in jq are internally represented by their IEEE754 double precision approximation\. Any arithmetic operation with numbers, whether they are literals or results of previous filters, will produce a double precision floating point result\.503Numbers in jq are internally represented by their IEEE754 double precision approximation\. Any arithmetic operation with numbers, whether they are literals or results of previous filters, will produce a double precision floating point result\.504.505.P489However, when parsing a literal jq will store the original literal string\. If no mutation is applied to this value then it will make to the output in its original form, even if conversion to double would result in a loss\. 506However, when parsing a literal jq will store the original literal string\. If no mutation is applied to this value then it will make to the output in its original form, even if conversion to double would result in a loss\.507.508.SS "Array construction: []"509As in JSON, \fB[]\fR is used to construct arrays, as in \fB[1,2,3]\fR\. The elements of the arrays can be any jq expression, including a pipeline\. All of the results produced by all of the expressions are collected into one big array\. You can use it to construct an array out of a known quantity of values (as in \fB[\.foo, \.bar, \.baz]\fR) or to "collect" all the results of a filter into an array (as in \fB[\.items[]\.name]\fR)510.
139 unmodified lines
650.IP "" 4651.652.nf653637{"f o o":"f o o","b a r":"f o o"}654{"foo":"f o o","b a r":"f o o"}655656jq \'{user, title: \.titles[]}\'657 {"user":"stedolan","titles":["JQ Primer", "More JQ"]}658=> {"user":"stedolan", "title": "JQ Primer"}, {"user":"stedolan", "title": "More JQ"}
24 unmodified lines
683.684.IP "" 0685.686.SH "BUILTIN OPERATORS AND FUNCTIONS"670Some jq operator (for instance, \fB+\fR) 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\.687Some jq operators (for instance, \fB+\fR) 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\.688.689.P673Please note that all numbers are converted to IEEE754 double precision floating point representation\. Arithmetic and logical operators are working with these converted doubles\. Results of all such operations are also limited to the double precision\. 690Please note that all numbers are converted to IEEE754 double precision floating point representation\. Arithmetic and logical operators are working with these converted doubles\. Results of all such operations are also limited to the double precision\.691.692.P676The only exception to this behaviour of number is a snapshot of original number literal\. When a number which originally was provided as a literal is never mutated until the end of the program then it is printed to the output in its original literal form\. This also includes cases when the original literal would be truncated when converted to the IEEE754 double precision floating point number\.693The only exception to this behaviour of number is a snapshot of original number literal\. When a number which originally was provided as a literal is never mutated until the end of the program then it is printed to the output in its original literal form\. This also includes cases when the original literal would be truncated when converted to the IEEE754 double precision floating point number\.694.695.SS "Addition: +"696The operator \fB+\fR takes two filters, applies them both to the same input, and adds the results together\. What "adding" means depends on the types involved:697.
60 unmodified lines
758.fi759.760.IP "" 0761.745.SS "Multiplication, division, modulo: *, /, and %"762.SS "Multiplication, division, modulo: *, /, %"763These infix operators behave as expected when given two numbers\. Division by zero raises an error\. \fBx % y\fR computes x modulo y\.764.765.P749Multiplying a string by a number produces the concatenation of that string that many times\. \fB"x" * 0\fR produces \fBnull\fR\.766Multiplying a string by a number produces the concatenation of that string that many times\. \fB"x" * 0\fR produces \fB""\fR\.767.768.P769Dividing a string by another splits the first using the second as separators\.770.
30 unmodified lines
801.IP "\(bu" 4802The length of a \fBstring\fR is the number of Unicode codepoints it contains (which will be the same as its JSON\-encoded length in bytes if it\'s pure ASCII)\.803.804.IP "\(bu" 4805The length of a \fBnumber\fR is its absolute value\.806.807.IP "\(bu" 4808The length of an \fBarray\fR is the number of elements\.809.810.IP "\(bu" 4811The length of an \fBobject\fR is the number of key\-value pairs\.812.813.IP "\(bu" 4814The length of \fBnull\fR is zero\.815.816.IP "\(bu" 4817It is an error to use \fBlength\fR on a \fBboolean\fR\.818.819.IP "" 4820.821.nf822823jq \'\.[] | length\'801 [[1,2], "string", {"a":2}, null]802=> 2, 6, 1, 0824 [[1,2], "string", {"a":2}, null, \-5]825=> 2, 6, 1, 0, 5826.827.fi828.829.IP "" 0
81 unmodified lines
911.fi912.913.IP "" 0914.892.SS "map(x), map_values(x)"893For any filter \fBx\fR, \fBmap(x)\fR will run that filter for each element of the input array, and return the outputs in a new array\. \fBmap(\.+1)\fR will increment each element of an array of numbers\.915.SS "map(f), map_values(f)"916For any filter \fBf\fR, \fBmap(f)\fR and \fBmap_values(f)\fR apply \fBf\fR to each of the values in the input array or object, that is, to the values of \fB\.[]\fR\.917.918.P896Similarly, \fBmap_values(x)\fR will run that filter for each element, but it will return an object when an object is passed\.919In the absence of errors, \fBmap(f)\fR always outputs an array whereas \fBmap_values(f)\fR outputs an array if given an array, or an object if given an object\.920.921.P899\fBmap(x)\fR is equivalent to \fB[\.[] | x]\fR\. In fact, this is how it\'s defined\. Similarly, \fBmap_values(x)\fR is defined as \fB\.[] |= x\fR\.922When the input to \fBmap_values(f)\fR is an object, the output object has the same keys as the input object except for those keys whose values when piped to \fBf\fR produce no values at all\.923.924.P925The key difference between \fBmap(f)\fR and \fBmap_values(f)\fR is that the former simply forms an array from all the values of \fB($x|f)\fR for each value, $x, in the input array or object, but \fBmap_values(f)\fR only uses \fBfirst($x|f)\fR\.926.927.P928Specifically, for object inputs, \fBmap_value(f)\fR constructs the output object by examining in turn the value of \fBfirst(\.[$k]|f)\fR for each key, $k, of the input\. If this expression produces no values, then the corresponding key will be dropped; otherwise, the output object will have that value at the key, $k\.929.930.P931Here 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:932.933.P934map(\.+1) #=> [2] map(\., \.) #=> [1,1] map(empty) #=> []935.936.P937map_values(\.+1) #=> [2] map_values(\., \.) #=> [1] map_values(empty) #=> []938.939.P940\fBmap(f)\fR is equivalent to \fB[\.[] | f]\fR and \fBmap_values(f)\fR is equivalent to \fB\.[] |= f\fR\.941.942.P943In fact, these are their implementations\.944.945.IP "" 4946.947.nf948
3 unmodified lines
952953jq \'map_values(\.+1)\'954 {"a": 1, "b": 2, "c": 3}955=> {"a": 2, "b": 3, "c": 4}956957jq \'map(\., \.)\'958 [1,2]959=> [1,1,2,2]960961jq \'map_values(\. // empty)\'962 {"a": null, "b": true, "c": false}963=> {"b":true}964.965.fi966.967.IP "" 0968.969.SS "pick(pathexps)"970Emit the projection of the input object or array defined by the specified sequence of path expressions, such that if p is any one of these specifications, then \fB(\. | p)\fR will evaluate to the same value as \fB(\. | pick(pathexps) | p)\fR\. For arrays, negative indices and \.[m:n] specifications should not be used\.971.972.IP "" 4973.974.nf975976jq \'pick(\.a, \.b\.c, \.x)\'977 {"a": 1, "b": {"c": 2, "d": 3}, "e": 4}978=> {"a":1,"b":{"c":2},"x":null}979980jq \'[1,2,3,4] | pick(\.[2], \.[0], \.[0])\'981 [1,2,3,4]982=> [1,null,3]983.984.fi985.986.IP "" 0987.988.SS "path(path_expression)"989Outputs array representations of the given path expression in \fB\.\fR\. The outputs are arrays of strings (object keys) and/or numbers (array indices)\.990.991.P
99 unmodified lines
1091.fi1092.1093.IP "" 01094.1024.SS "to_entries, from_entries, with_entries"1095.SS "to_entries, from_entries, with_entries(f)"1096These functions convert between an object and an array of key\-value pairs\. If \fBto_entries\fR is passed an object, then for each \fBk: v\fR entry in the input, the output array includes \fB{"key": k, "value": v}\fR\.1097.1098.P1028\fBfrom_entries\fR does the opposite conversion, and \fBwith_entries(foo)\fR is a shorthand for \fBto_entries | map(foo) | from_entries\fR, useful for doing some operation to all keys and values of an object\. \fBfrom_entries\fR accepts key, Key, name, Name, value and Value as keys\.1099\fBfrom_entries\fR does the opposite conversion, and \fBwith_entries(f)\fR is a shorthand for \fBto_entries | map(f) | from_entries\fR, useful for doing some operation to all keys and values of an object\. \fBfrom_entries\fR accepts \fB"key"\fR, \fB"Key"\fR, \fB"name"\fR, \fB"Name"\fR, \fB"value"\fR, and \fB"Value"\fR as keys\.1100.1101.IP "" 41102.1103.nf
14 unmodified lines
1118.1119.IP "" 01120.1121.SS "select(boolean_expression)"1051The function \fBselect(foo)\fR produces its input unchanged if \fBfoo\fR returns true for that input, and produces no output otherwise\.1122The function \fBselect(f)\fR produces its input unchanged if \fBf\fR returns true for that input, and produces no output otherwise\.1123.1124.P1125It\'s useful for filtering lists: \fB[1,2,3] | map(select(\. >= 2))\fR will give you \fB[2,3]\fR\.1126.
79 unmodified lines
1206.fi1207.1208.IP "" 01209.1139.SS "paths, paths(node_filter), leaf_paths"1210.SS "paths, paths(node_filter)"1211\fBpaths\fR outputs the paths to all the elements in its input (except it does not output the empty list, representing \. itself)\.1212.1213.P1143\fBpaths(f)\fR outputs the paths to any values for which \fBf\fR is true\. That is, \fBpaths(numbers)\fR outputs the paths to all numeric values\.1214\fBpaths(f)\fR outputs the paths to any values for which \fBf\fR is \fBtrue\fR\. That is, \fBpaths(type == "number")\fR outputs the paths to all numeric values\.1215.1145.P1146\fBleaf_paths\fR is an alias of \fBpaths(scalars)\fR; \fBleaf_paths\fR is \fIdeprecated\fR and will be removed in the next major release\.1147.1216.IP "" 41217.1218.nf12191220jq \'[paths]\'1221 [1,[[],{"a":2}]]1222=> [[0],[1],[1,0],[1,1],[1,1,"a"]]12231156jq \'[paths(scalars)]\'1224jq \'[paths(type == "number")]\'1225 [1,[[],{"a":2}]]1226=> [[0],[1,1,"a"]]1227.1228.fi
119 unmodified lines
1348.fi1349.1350.IP "" 01351.1284.SS "range(upto), range(from;upto), range(from;upto;by)"1285The \fBrange\fR function produces a range of numbers\. \fBrange(4;10)\fR produces 6 numbers, from 4 (inclusive) to 10 (exclusive)\. The numbers are produced as separate outputs\. Use \fB[range(4;10)]\fR to get a range as an array\.1352.SS "range(upto), range(from; upto), range(from; upto; by)"1353The \fBrange\fR function produces a range of numbers\. \fBrange(4; 10)\fR produces 6 numbers, from 4 (inclusive) to 10 (exclusive)\. The numbers are produced as separate outputs\. Use \fB[range(4; 10)]\fR to get a range as an array\.1354.1355.P1356The one argument form generates numbers from 0 to the given number, with an increment of 1\.1357.
6 unmodified lines
1364.IP "" 41365.1366.nf13671300jq \'range(2;4)\'1368jq \'range(2; 4)\'1369 null1370=> 2, 313711304jq \'[range(2;4)]\'1372jq \'[range(2; 4)]\'1373 null1374=> [2,3]13751376jq \'[range(4)]\'1377 null1378=> [0,1,2,3]13791312jq \'[range(0;10;3)]\'1380jq \'[range(0; 10; 3)]\'1381 null1382=> [0,3,6,9]13831316jq \'[range(0;10;\-1)]\'1384jq \'[range(0; 10; \-1)]\'1385 null1386=> []13871320jq \'[range(0;\-5;\-1)]\'1388jq \'[range(0; \-5; \-1)]\'1389 null1390=> [0,\-1,\-2,\-3,\-4]1391.1392.fi
132 unmodified lines
1525.P1526\fBsort\fR may be used to sort by a particular field of an object, or by applying any jq filter\.1527.1528.P1461\fBsort_by(foo)\fR compares two elements by comparing the result of \fBfoo\fR on each element\.1529\fBsort_by(f)\fR compares two elements by comparing the result of \fBf\fR on each element\.1530.1531.IP "" 41532.1533.nf
306 unmodified lines
1840.1841.SS "split(str)"1842Splits an input string on the separator argument\.1843.1844.P1845\fBsplit\fR can also split on regex matches when called with two arguments (see the regular expressions section below)\.1846.1847.IP "" 41848.1849.nf1850
83 unmodified lines
1934.fi1935.1936.IP "" 01937.1867.SS "recurse(f), recurse, recurse(f; condition), recurse_down"1938.SS "recurse(f), recurse, recurse(f; condition)"1939The \fBrecurse(f)\fR function allows you to search through a recursive structure, and extract interesting data from all levels\. Suppose your input represents a filesystem:1940.1941.IP "" 41942.
33 unmodified lines
1976.P1977\fBrecurse(f; condition)\fR is a generator which begins by emitting \. and then emits in turn \.|f, \.|f|f, \.|f|f|f, \.\.\. so long as the computed value satisfies the condition\. For example, to generate all the integers, at least in principle, one could write \fBrecurse(\.+1; true)\fR\.1978.1979.P1909For legacy reasons, \fBrecurse_down\fR exists as an alias to calling \fBrecurse\fR without arguments\. This alias is considered \fIdeprecated\fR and will be removed in the next major release\.1910.1911.P1980The recursive calls in \fBrecurse\fR will not consume additional memory whenever \fBf\fR produces at most a single output for each input\.1981.1982.IP "" 41983.
96 unmodified lines
2080.fi2081.2082.IP "" 02083.2016.SS "String interpolation \- \e(foo)"2084.SS "String interpolation: \e(exp)"2085Inside a string, you can put an expression inside parens after a backslash\. Whatever the expression returns will be interpolated into the string\.2086.2087.IP "" 42088.
243 unmodified lines
2332.2333.SH "CONDITIONALS AND COMPARISONS"2334.2335.SS "==, !="2268The expression \'a == b\' will produce \'true\' if the result of a and b are equal (that is, if they represent equivalent JSON documents) and \'false\' otherwise\. In particular, strings are never considered equal to numbers\. If you\'re coming from JavaScript, jq\'s == is like JavaScript\'s === \- considering values equal only when they have the same type as well as the same value\.2336The expression \'a == b\' will produce \'true\' if the results of evaluating a and b are equal (that is, if they represent equivalent JSON values) and \'false\' otherwise\. In particular, strings are never considered equal to numbers\. In checking for the equality of JSON objects, the ordering of keys is irrelevant\. If you\'re coming from JavaScript, please note that jq\'s \fB==\fR is like JavaScript\'s \fB===\fR, the "strict equality" operator\.2337.2338.P2339!= is "not equal", and \'a != b\' returns the opposite value of \'a == b\'2340.2341.IP "" 42342.2343.nf23442345jq \'\. == false\'2346 null2347=> false23482349jq \'\. == {"b": {"d": (4 + 1e\-20), "c": 3}, "a":1}\'2350 {"a":1, "b": {"c": 3, "d": 4}}2351=> true23522353jq \'\.[] == 1\'2354 [1, 1\.0, "1", "banana"]2355=> true, true, false, false2356.2357.fi2358.2359.IP "" 02360.2285.SS "if\-then\-else"2361.SS "if\-then\-else\-end"2362\fBif A then B else C end\fR will act the same as \fBB\fR if \fBA\fR produces a value other than false or null, but act the same as \fBC\fR otherwise\.2363.2364.P2289\fBif A then B end\fR is the same as \fBif A then B else \. end\fR\. That is, the \fBelse\fR branch is optional, and if absent is the same as \fB\.\fR\.2365\fBif A then B end\fR is the same as \fBif A then B else \. end\fR\. That is, the \fBelse\fR branch is optional, and if absent is the same as \fB\.\fR\. This also applies to \fBelif\fR with absent ending \fBelse\fR branch\.2366.2367.P2292Checking for false or null is a simpler notion of "truthiness" than is found in JavaScript or Python, but it means that you\'ll sometimes have to be more explicit about the condition you want\. You can\'t test whether, e\.g\. a string is empty using \fBif \.name then A else B end\fR, you\'ll need something more like \fBif \.name == "" then A else B end\fR instead\.2368Checking for false or null is a simpler notion of "truthiness" than is found in JavaScript or Python, but it means that you\'ll sometimes have to be more explicit about the condition you want\. You can\'t test whether, e\.g\. a string is empty using \fBif \.name then A else B end\fR; you\'ll need something like \fBif \.name == "" then A else B end\fR instead\.2369.2370.P2371If the condition \fBA\fR produces multiple results, then \fBB\fR is evaluated once for each result that is not false or null, and \fBC\fR is evaluated once for each false or null\.2372.
3 unmodified lines
2376.IP "" 42377.2378.nf23792304jq \'if \. == 0 then "zero" elif \. == 1 then "one" else "many" end\'2380jq \'if \. == 0 then2381 "zero"2382elif \. == 1 then2383 "one"2384else2385 "many"2386end\'2387 22388=> "many"2389.2390.fi
17 unmodified lines
2408.fi2409.2410.IP "" 02411.2330.SS "and/or/not"2331jq 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"\.2412.SS "and, or, not"2413jq supports the normal Boolean operators \fBand\fR, \fBor\fR, \fBnot\fR\. They have the same standard of truth as if expressions \- \fBfalse\fR and \fBnull\fR are considered "false values", and anything else is a "true value"\.2414.2415.P2416If an operand of one of these operators produces multiple results, the operator itself will produce a result for each input\.2417.2418.P2419\fBnot\fR is in fact a builtin function rather than an operator, so it is called as a filter to which things can be piped rather than with special syntax, as in \fB\.foo and \.bar | not\fR\.2420.2421.P2340These 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\.2422These three only produce the values \fBtrue\fR and \fBfalse\fR, 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 \fB//\fR operator below\.2423.2424.IP "" 42425.2426.nf
78 unmodified lines
25052506# Repeat an expression until it raises "break" as an2507# error, then stop repeating without re\-raising the error\.2508# But if the error caught is not "break" then re\-raise it\.2427try repeat(exp) catch \.=="break" then empty else error;2509try repeat(exp) catch if \.=="break" then empty else error2510.2511.fi2512.2513.IP "" 0
52 unmodified lines
2566.IP "" 42567.2568.nf25692488jq \'[\.[]|(\.a)?]\'2570jq \'[\.[] | \.a?]\'2571 [{}, true, {"a":1}]2572=> [null, 1]25732574jq \'[\.[] | tonumber?]\'2575 ["1", "invalid", "3", 4]2576=> [1, 3, 4]2577.2578.fi2579.2580.IP "" 02581.2496.SH "REGULAR EXPRESSIONS (PCRE)"2497jq uses the Oniguruma regular expression library, as do php, ruby, TextMate, Sublime Text, etc, so the description here will focus on jq specifics\.2582.SH "REGULAR EXPRESSIONS"2583jq uses the 2584.2585.P2586Oniguruma supports several flavors of regular expression, so it is important to know that jq uses the 2587.2588.P2589The jq regex filters are defined so that they can be used using one of these patterns:2590.2591.IP "" 42592.2593.nf25942506STRING | FILTER( REGEX )2507STRING | FILTER( REGEX; FLAGS )2508STRING | FILTER( [REGEX] )2509STRING | FILTER( [REGEX, FLAGS] )2595STRING | FILTER(REGEX)2596STRING | FILTER(REGEX; FLAGS)2597STRING | FILTER([REGEX])2598STRING | FILTER([REGEX, FLAGS])2599.2600.fi2601.2602.IP "" 0
1 unmodified line
2604.P2605where:2606.2607.IP "\(bu" 42519STRING, REGEX and FLAGS are jq strings and subject to jq string interpolation;2608STRING, REGEX, and FLAGS are jq strings and subject to jq string interpolation;2609.2610.IP "\(bu" 42522REGEX, after string interpolation, should be a valid PCRE regex;2611REGEX, after string interpolation, should be a valid regular expression;2612.2613.IP "\(bu" 42614FILTER is one of \fBtest\fR, \fBmatch\fR, or \fBcapture\fR, as described below\.2615.2616.IP "" 02617.2618.P2619Since REGEX must evaluate to a JSON string, some characters that are needed to form a regular expression must be escaped\. For example, the regular expression \fB\es\fR signifying a whitespace character would be written as \fB"\e\es"\fR\.2620.2621.P2622FLAGS is a string consisting of one of more of the supported flags:2623.2624.IP "\(bu" 42625\fBg\fR \- Global search (find all matches, not just the first)
1 unmodified line
2627.IP "\(bu" 42628\fBi\fR \- Case insensitive search2629.2630.IP "\(bu" 42539\fBm\fR \- Multi line mode (\'\.\' will match newlines)2631\fBm\fR \- Multi line mode (\fB\.\fR will match newlines)2632.2633.IP "\(bu" 42634\fBn\fR \- Ignore empty matches2635.2636.IP "\(bu" 42637\fBp\fR \- Both s and m modes are enabled2638.2639.IP "\(bu" 42548\fBs\fR \- Single line mode (\'^\' \-> \'\eA\', \'$\' \-> \'\eZ\')2640\fBs\fR \- Single line mode (\fB^\fR \-> \fB\eA\fR, \fB$\fR \-> \fB\eZ\fR)2641.2642.IP "\(bu" 42643\fBl\fR \- Find longest possible matches2644.
2 unmodified lines
2647.2648.IP "" 02649.2650.P2559To match whitespace in an x pattern use an escape such as \es, e\.g\.2651To match a whitespace with the \fBx\fR flag, use \fB\es\fR, e\.g\.2652.2561.IP "\(bu" 42562test( "a\e\esb"; "x" )2653.IP "" 42654.2655.nf26562657jq \-n \'"a b" | test("a\e\esb"; "x")\'2658.2659.fi2660.2661.IP "" 02662.2663.P2664Note that certain flags may also be specified within REGEX, e\.g\.2665.2569.IP "\(bu" 42570jq \-n \'("test", "TEst", "teST", "TEST") | test( "(?i)te(?\-i)st" )\'2666.IP "" 42667.2668.nf26692670jq \-n \'("test", "TEst", "teST", "TEST") | test("(?i)te(?\-i)st")\'2671.2672.fi2673.2674.IP "" 02675.2676.P2575evaluates to: true, true, false, false\.2677evaluates to: \fBtrue\fR, \fBtrue\fR, \fBfalse\fR, \fBfalse\fR\.2678.2679.SS "test(val), test(regex; flags)"2680Like \fBmatch\fR, but does not return match objects, only \fBtrue\fR or \fBfalse\fR for whether or not the regex matches the input\.2681.
96 unmodified lines
2778.SS "scan(regex), scan(regex; flags)"2779Emit a stream of the non\-overlapping substrings of the input that match the regex in accordance with the flags, if any have been specified\. If there is no match, the stream is empty\. To capture all the matches for each input string, use the idiom \fB[ expr ]\fR, e\.g\. \fB[ scan(regex) ]\fR\.2780.2781.SS "split(regex; flags)"2680For backwards compatibility, \fBsplit\fR splits on a string, not a regex\.2782Splits an input string on each regex match\.2783.2784.P2785For backwards compatibility, when called with a single argument, \fBsplit\fR splits on a string, not a regex\.2786.2787.SS "splits(regex), splits(regex; flags)"2788These provide the same results as their \fBsplit\fR counterparts, but as a stream instead of an array\.2789.2685.SS "sub(regex; tostring), sub(regex; string; flags)"2686Emit the string obtained by replacing the first match of regex in the input string with \fBtostring\fR, after interpolation\. \fBtostring\fR should be a jq string, and may contain references to named captures\. The named captures are, in effect, presented as a JSON object (as constructed by \fBcapture\fR) to \fBtostring\fR, so a reference to a captured variable named "x" would take the form: "(\.x)"\.2790.SS "sub(regex; tostring), sub(regex; tostring; flags)"2791Emit the string obtained by replacing the first match of regex in the input string with \fBtostring\fR, after interpolation\. \fBtostring\fR should be a jq string or a stream of such strings, each of which may contain references to named captures\. The named captures are, in effect, presented as a JSON object (as constructed by \fBcapture\fR) to \fBtostring\fR, so a reference to a captured variable named "x" would take the form: \fB"\e(\.x)"\fR\.2792.2688.SS "gsub(regex; string), gsub(regex; string; flags)"2689\fBgsub\fR is like \fBsub\fR but all the non\-overlapping occurrences of the regex are replaced by the string, after interpolation\.2793.SS "gsub(regex; tostring), gsub(regex; tostring; flags)"2794\fBgsub\fR is like \fBsub\fR but all the non\-overlapping occurrences of the regex are replaced by \fBtostring\fR, after interpolation\. If the second argument is a stream of jq strings, then \fBgsub\fR will produce a corresponding stream of JSON strings\.2795.2796.SH "ADVANCED FEATURES"2797Variables are an absolute necessity in most programming languages, but they\'re relegated to an "advanced feature" in jq\.2798.2799.P2800In most languages, variables are the only means of passing around data\. If you calculate a value, and you want to use it more than once, you\'ll need to store it in a variable\. To pass a value to another part of the program, you\'ll need that part of the program to define a variable (as a function parameter, object member, or whatever) in which to place the data\.2801.2802.P2698It is also possible to define functions in jq, although this is is a feature whose biggest use is defining jq\'s standard library (many jq functions such as \fBmap\fR and \fBfind\fR are in fact written in jq)\.2803It is also possible to define functions in jq, although this is is a feature whose biggest use is defining jq\'s standard library (many jq functions such as \fBmap\fR and \fBselect\fR are in fact written in jq)\.2804.2805.P2806jq has reduction operators, which are very powerful but a bit tricky\. Again, these are mostly used internally, to define some useful bits of jq\'s standard library\.2807.
34 unmodified lines
2842.IP "" 42843.2844.nf28452741{"posts": [{"title": "Frist psot", "author": "anon"},2846{"posts": [{"title": "First post", "author": "anon"},2847 {"title": "A well\-written article", "author": "person1"}],2848 "realnames": {"anon": "Anonymous Coward",2849 "person1": "Person McPherson"}}2850.
7 unmodified lines
2858.IP "" 42859.2860.nf28612757{"title": "Frist psot", "author": "Anonymous Coward"}2862{"title": "First post", "author": "Anonymous Coward"}2863{"title": "A well\-written article", "author": "Person McPherson"}2864.2865.fi2866.
15 unmodified lines
2882.P2883The expression \fBexp as $x | \.\.\.\fR means: for each value of expression \fBexp\fR, run the rest of the pipeline with the entire original input, and with \fB$x\fR set to that value\. Thus \fBas\fR functions as something of a foreach loop\.2884.2885.P2781Just as \fB{foo}\fR is a handy way of writing \fB{foo: \.foo}\fR, so \fB{$foo}\fR is a handy way of writing \fB{foo:$foo}\fR\.2886Just as \fB{foo}\fR is a handy way of writing \fB{foo: \.foo}\fR, so \fB{$foo}\fR is a handy way of writing \fB{foo: $foo}\fR\.2887.2888.P2889Multiple variables may be declared using a single \fBas\fR expression by providing a pattern that matches the structure of the input (this is known as "destructuring"):2890.
309 unmodified lines
3200.SS "first(expr), last(expr), nth(n; expr)"3201The \fBfirst(expr)\fR and \fBlast(expr)\fR functions extract the first and last values from \fBexpr\fR, respectively\.3202.3203.P3099The \fBnth(n; expr)\fR function extracts the nth value output by \fBexpr\fR\. This can be defined as \fBdef nth(n; expr): last(limit(n + 1; expr));\fR\. Note that \fBnth(n; expr)\fR doesn\'t support negative values of \fBn\fR\.3204The \fBnth(n; expr)\fR function extracts the nth value output by \fBexpr\fR\. Note that \fBnth(n; expr)\fR doesn\'t support negative values of \fBn\fR\.3205.3206.IP "" 43207.3208.nf
240 unmodified lines
3449.P3450Note too that \fB\.a,\.b=0\fR does not set \fB\.a\fR and \fB\.b\fR, but \fB(\.a,\.b)=0\fR sets both\.3451.3452.SS "Update\-assignment: |="3348This is the "update" operator \'|=\'\. It takes a filter on the right\-hand side and works out the new value for the property of \fB\.\fR being assigned to by running the old value through this expression\. For instance, (\.foo, \.bar) |= \.+1 will build an object with the "foo" field set to the input\'s "foo" plus 1, and the "bar" field set to the input\'s "bar" plus 1\.3453This is the "update" operator \fB|=\fR\. It takes a filter on the right\-hand side and works out the new value for the property of \fB\.\fR being assigned to by running the old value through this expression\. For instance, \fB(\.foo, \.bar) |= \.+1\fR will build an object with the \fBfoo\fR field set to the input\'s \fBfoo\fR plus 1, and the \fBbar\fR field set to the input\'s \fBbar\fR plus 1\.3454.3455.P3456The left\-hand side can be any general path expression; see \fBpath()\fR\.3457.3458.P3354Note that the left\-hand side of \'|=\' refers to a value in \fB\.\fR\. Thus \fB$var\.foo |= \. + 1\fR won\'t work as expected (\fB$var\.foo\fR is not a valid or useful path expression in \fB\.\fR); use \fB$var | \.foo |= \. + 1\fR instead\.3459Note that the left\-hand side of \fB|=\fR refers to a value in \fB\.\fR\. Thus \fB$var\.foo |= \. + 1\fR won\'t work as expected (\fB$var\.foo\fR is not a valid or useful path expression in \fB\.\fR); use \fB$var | \.foo |= \. + 1\fR instead\.3460.3461.P3462If the right\-hand side outputs no values (i\.e\., \fBempty\fR), then the left\-hand side path will be deleted, as with \fBdel(path)\fR\.3463.
27 unmodified lines
3491.3492.IP "" 03493.3494.SS "Plain assignment: ="3390This is the plain assignment operator\. Unlike the others, the input to the right\-hand\-side (RHS) is the same as the input to the left\-hand\-side (LHS) rather than the value at the LHS path, and all values output by the RHS will be used (as shown below)\.3495This is the plain assignment operator\. Unlike the others, the input to the right\-hand side (RHS) is the same as the input to the left\-hand side (LHS) rather than the value at the LHS path, and all values output by the RHS will be used (as shown below)\.3496.3497.P3393If the RHS of \'=\' produces multiple values, then for each such value jq will set the paths on the left\-hand side to the value and then it will output the modified \fB\.\fR\. For example, \fB(\.a,\.b)=range(2)\fR outputs \fB{"a":0,"b":0}\fR, then \fB{"a":1,"b":1}\fR\. The "update" assignment forms (see above) do not do this\.3498If the RHS of \fB=\fR produces multiple values, then for each such value jq will set the paths on the left\-hand side to the value and then it will output the modified \fB\.\fR\. For example, \fB(\.a,\.b) = range(2)\fR outputs \fB{"a":0,"b":0}\fR, then \fB{"a":1,"b":1}\fR\. The "update" assignment forms (see above) do not do this\.3499.3500.P3396This example should show the difference between \'=\' and \'|=\':3501This example should show the difference between \fB=\fR and \fB|=\fR:3502.3503.P3399Provide input \'{"a": {"b": 10}, "b": 20}\' to the programs:3504Provide input \fB{"a": {"b": 10}, "b": 20}\fR to the programs3505.3506.IP "" 43507.3508.nf35093510\&.a = \.b34063407\&.a |= \.b3511.3512.fi3513.3514.IP "" 03515.3516.P3414The former will set the "a" field of the input to the "b" field of the input, and produce the output {"a": 20, "b": 20}\. The latter will set the "a" field of the input to the "a" field\'s "b" field, producing {"a": 10, "b": 20}\.3517and3518.3416.P3417Another example of the difference between \'=\' and \'|=\':3418.3519.IP "" 43520.3521.nf35223423null|(\.a,\.b)=range(3)3523\&.a |= \.b3524.3525.fi3526.3527.IP "" 03528.3529.P3430outputs \'{"a":0,"b":0}\', \'{"a":1,"b":1}\', and \'{"a":2,"b":2}\', while3530The former will set the \fBa\fR field of the input to the \fBb\fR field of the input, and produce the output \fB{"a": 20, "b": 20}\fR\. The latter will set the \fBa\fR field of the input to the \fBa\fR field\'s \fBb\fR field, producing \fB{"a": 10, "b": 20}\fR\.3531.3532.IP "" 43533.3534.nf35353436null|(\.a,\.b)|=range(3)3536jq \'\.a = \.b\'3537 {"a": {"b": 10}, "b": 20}3538=> {"a":20,"b":20}35393540jq \'\.a |= \.b\'3541 {"a": {"b": 10}, "b": 20}3542=> {"a":10,"b":20}35433544jq \'(\.a, \.b) = range(3)\'3545 null3546=> {"a":0,"b":0}, {"a":1,"b":1}, {"a":2,"b":2}35473548jq \'(\.a, \.b) |= range(3)\'3549 null3550=> {"a":0,"b":0}3551.3552.fi3553.3554.IP "" 03555.3442.P3443outputs just \'{"a":0,"b":0}\'\.3444.3556.SS "Complex assignments"3557Lots 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:3558.3559.IP "" 4
61 unmodified lines
3621.P3622Paths in the a search path are subject to various substitutions\.3623.3624.P3514For paths starting with "~/", the user\'s home directory is substituted for "~"\.3625For paths starting with \fB~/\fR, the user\'s home directory is substituted for \fB~\fR\.3626.3627.P3517For paths starting with "$ORIGIN/", the path of the jq executable is substituted for "$ORIGIN"\.3628For paths starting with \fB$ORIGIN/\fR, the directory where the jq executable is located is substituted for \fB$ORIGIN\fR\.3629.3630.P3520For paths starting with "\./" or paths that are "\.", the path of the including file is substituted for "\."\. For top\-level programs given on the command\-line, the current directory is used\.3631For paths starting with \fB\./\fR or paths that are \fB\.\fR, the path of the including file is substituted for \fB\.\fR\. For top\-level programs given on the command\-line, the current directory is used\.3632.3633.P3634Import directives can optionally specify a search path to which the default is appended\.3635.
3 unmodified lines
3639.P3640Null and empty string path elements terminate search path processing\.3641.3642.P3532A dependency with relative path "foo/bar" would be searched for in "foo/bar\.jq" and "foo/bar/bar\.jq" in the given search path\. This is intended to allow modules to be placed in a directory along with, for example, version control files, README files, and so on, but also to allow for single\-file modules\.3643A dependency with relative path \fBfoo/bar\fR would be searched for in \fBfoo/bar\.jq\fR and \fBfoo/bar/bar\.jq\fR in the given search path\. This is intended to allow modules to be placed in a directory along with, for example, version control files, README files, and so on, but also to allow for single\-file modules\.3644.3645.P3535Consecutive components with the same name are not allowed to avoid ambiguities (e\.g\., "foo/foo")\.3646Consecutive components with the same name are not allowed to avoid ambiguities (e\.g\., \fBfoo/foo\fR)\.3647.3648.P3649For example, with \fB\-L$HOME/\.jq\fR a module \fBfoo\fR can be found in \fB$HOME/\.jq/foo\.jq\fR and \fB$HOME/\.jq/foo/foo\.jq\fR\.3650.3651.P3541If "$HOME/\.jq" is a file, it is sourced into the main program\.3652If \fB$HOME/\.jq\fR is a file, it is sourced into the main program\.3653.3654.SS "import RelativePathString as NAME [<metadata>];"3544Imports a module found at the given path relative to a directory in a search path\. A "\.jq" suffix will be added to the relative path string\. The module\'s symbols are prefixed with "NAME::"\.3655Imports a module found at the given path relative to a directory in a search path\. A \fB\.jq\fR suffix will be added to the relative path string\. The module\'s symbols are prefixed with \fBNAME::\fR\.3656.3657.P3547The optional metadata must be a constant jq expression\. It should be an object with keys like "homepage" and so on\. At this time jq only uses the "search" key/value of the metadata\. The metadata is also made available to users via the \fBmodulemeta\fR builtin\.3658The optional metadata must be a constant jq expression\. It should be an object with keys like \fBhomepage\fR and so on\. At this time jq only uses the \fBsearch\fR key/value of the metadata\. The metadata is also made available to users via the \fBmodulemeta\fR builtin\.3659.3660.P3550The "search" key in the metadata, if present, should have a string or array value (array of strings); this is the search path to be prefixed to the top\-level search path\.3661The \fBsearch\fR key in the metadata, if present, should have a string or array value (array of strings); this is the search path to be prefixed to the top\-level search path\.3662.3663.SS "include RelativePathString [<metadata>];"3553Imports a module found at the given path relative to a directory in a search path as if it were included in place\. A "\.jq" suffix will be added to the relative path string\. The module\'s symbols are imported into the caller\'s namespace as if the module\'s content had been included directly\.3664Imports a module found at the given path relative to a directory in a search path as if it were included in place\. A \fB\.jq\fR suffix will be added to the relative path string\. The module\'s symbols are imported into the caller\'s namespace as if the module\'s content had been included directly\.3665.3666.P3556The optional metadata must be a constant jq expression\. It should be an object with keys like "homepage" and so on\. At this time jq only uses the "search" key/value of the metadata\. The metadata is also made available to users via the \fBmodulemeta\fR builtin\.3667The optional metadata must be a constant jq expression\. It should be an object with keys like \fBhomepage\fR and so on\. At this time jq only uses the \fBsearch\fR key/value of the metadata\. The metadata is also made available to users via the \fBmodulemeta\fR builtin\.3668.3669.SS "import RelativePathString as $NAME [<metadata>];"3559Imports a JSON file found at the given path relative to a directory in a search path\. A "\.json" suffix will be added to the relative path string\. The file\'s data will be available as \fB$NAME::NAME\fR\.3670Imports a JSON file found at the given path relative to a directory in a search path\. A \fB\.json\fR suffix will be added to the relative path string\. The file\'s data will be available as \fB$NAME::NAME\fR\.3671.3672.P3562The optional metadata must be a constant jq expression\. It should be an object with keys like "homepage" and so on\. At this time jq only uses the "search" key/value of the metadata\. The metadata is also made available to users via the \fBmodulemeta\fR builtin\.3673The optional metadata must be a constant jq expression\. It should be an object with keys like \fBhomepage\fR and so on\. At this time jq only uses the \fBsearch\fR key/value of the metadata\. The metadata is also made available to users via the \fBmodulemeta\fR builtin\.3674.3675.P3565The "search" key in the metadata, if present, should have a string or array value (array of strings); this is the search path to be prefixed to the top\-level search path\.3676The \fBsearch\fR key in the metadata, if present, should have a string or array value (array of strings); this is the search path to be prefixed to the top\-level search path\.3677.3678.SS "module <metadata>;"3679This directive is entirely optional\. It\'s not required for proper operation\. It serves only the purpose of providing metadata that can be read with the \fBmodulemeta\fR builtin\.3680.3681.P3571The metadata must be a constant jq expression\. It should be an object with keys like "homepage"\. At this time jq doesn\'t use this metadata, but it is made available to users via the \fBmodulemeta\fR builtin\.3682The metadata must be a constant jq expression\. It should be an object with keys like \fBhomepage\fR\. At this time jq doesn\'t use this metadata, but it is made available to users via the \fBmodulemeta\fR builtin\.3683.3684.SS "modulemeta"3574Takes a module name as input and outputs the module\'s metadata as an object, with the module\'s imports (including metadata) as an array value for the "deps" key\.3685Takes a module name as input and outputs the module\'s metadata as an object, with the module\'s imports (including metadata) as an array value for the \fBdeps\fR key\.3686.3687.P3688Programs can use this to query a module\'s metadata, which they could then use to, for example, search for, download, and install missing dependencies\.3689.
96 unmodified lines