|
| 1 | +# 1.x |
| 2 | + |
| 3 | +TODO: |
| 4 | +- Word about new organization and repo move? |
| 5 | +- Docker images |
| 6 | +- scan/2 added |
| 7 | +- sub/3 fixes |
| 8 | +- validate module metadata is object |
| 9 | +- Fix number lexer to avoid conflict with object indexing (#2254) |
| 10 | +- lots of docs fixes |
| 11 | + |
| 12 | +Changes |
| 13 | + |
| 14 | +- Use decimal number literals to preserve precision. Comparison operations respects precision but arithmetic operations might truncate. #1752 @leonid-s-usov |
| 15 | + ```sh |
| 16 | + # precision is preserved |
| 17 | + $ jq -n '100000000000000000' |
| 18 | + 100000000000000000 |
| 19 | + # comparsion respects precision (this is false in JavaScript) |
| 20 | + $ jq -n '100000000000000000 < 100000000000000001' |
| 21 | + true |
| 22 | + # arithmetic operations might truncate (same as JavaScript) |
| 23 | + $ jq -n '100000000000000000+10' |
| 24 | + 100000000000000020 |
| 25 | + ``` |
| 26 | +- Allow `if` without `else`-branch. When skipped the `else`-branch will be `.` (identity). #1825 @chancez #2481 @wader |
| 27 | + ```sh |
| 28 | + # convert 1 to "one" otherwise keep as is |
| 29 | + $ jq -n '1,2 | if . == 1 then "one" end' |
| 30 | + "one" |
| 31 | + 2 |
| 32 | + # behaves the same as |
| 33 | + $ jq -n '1,2 | if . == 1 then "one" else . end' |
| 34 | + "one" |
| 35 | + 2 |
| 36 | + # also works with elif |
| 37 | + $ jq -n '1,2,3 | if . == 1 then "one" elif . == 2 then "two" end |
| 38 | + "one" |
| 39 | + "two" |
| 40 | + 3 |
| 41 | + ``` |
| 42 | +- Allow use of `$binding` as key in object literals. 8ea4a55 @nicowilliams |
| 43 | + ```sh |
| 44 | + $ jq -n '"a" as $key | {$key: 123}' |
| 45 | + { |
| 46 | + "a": 123 |
| 47 | + } |
| 48 | + # previously parentheses were needed |
| 49 | + $ jq -n '"a" as $key | {($key): 123}' |
| 50 | + { |
| 51 | + "a": 123 |
| 52 | + } |
| 53 | + ``` |
| 54 | +- Last output value can now control exit code using `--exit-code`/`-e`. #1697 @ryo1kato |
| 55 | + ```sh |
| 56 | + # true-ish last output value exits with zero |
| 57 | + $ jq -ne true ; echo $? |
| 58 | + true |
| 59 | + 0 |
| 60 | + # false-ish last output value (false and null) exits with 1 |
| 61 | + $ jq -ne false ; echo $? |
| 62 | + false |
| 63 | + 1 |
| 64 | + # no output value exists with 4 |
| 65 | + $ jq -ne empty ; echo $? |
| 66 | + 4 |
| 67 | + ``` |
| 68 | +- Allow dot between chained indexes when using `.["index"]` #1168 @nicowilliams |
| 69 | + ```sh |
| 70 | + $ jq -n '{"a": {"b": 123}} | .a["b"]' |
| 71 | + 123 |
| 72 | + # now this works also |
| 73 | + $ jq -n '{"a": {"b": 123}} | .a.["b"]' |
| 74 | + 123 |
| 75 | + ``` |
| 76 | +- Speed up and refactor some builtins, also remove `scalars_or_empty/0`. #1845 @muhmuhten |
| 77 | +- Add `--binary`/`-b` on Windows for binary output. To get `\n` instead of `\r\n` line endings. 0dab2b1 @nicowilliams |
| 78 | +- Add `--nul-output`/`-0` for null (zero byte) separated output. #1990 @pabs3, #2235 @asottile |
| 79 | + ```sh |
| 80 | + # will output a zero byte after each output |
| 81 | + $ jq -n0 '1,2,3' | xxd |
| 82 | + 00000000: 3100 3200 3300 1.2.3. |
| 83 | + # can be used with xargs -0 |
| 84 | + $ jq -n -0 '"a","b","c"' | xargs -0 -n1 |
| 85 | + a |
| 86 | + b |
| 87 | + c |
| 88 | + $ jq -n -0 '"a b c", "d\ne\nf"' | xargs -0 printf '%q\n' |
| 89 | + 'a b c' |
| 90 | + 'd'$'\n''e'$'\n''f' |
| 91 | + # can be used with read -d '' |
| 92 | + $ while IFS= read -r -d '' json; do |
| 93 | + > jq '.name' <<< "$json" |
| 94 | + > done < <(jq -n -0 '{name:"a b c"},{name:"d\ne\nf"}') |
| 95 | + "a b c" |
| 96 | + "d\ne\nf" |
| 97 | + ``` |
| 98 | +- Fix issue converting string to number after previous convert error. #2400 @thalman |
| 99 | +
|
| 100 | +# Previous releases |
| 101 | +
|
| 102 | +Release history |
| 103 | +
|
| 104 | + * jq version 1.6 was released on Fri Nov 2 2018 |
| 105 | + * jq version 1.5 was released on Sat Aug 15 2015 |
| 106 | + * jq version 1.4 was released on Mon Jun 9 2014 |
| 107 | + * jq version 1.3 was released on Sun May 19 2013 |
| 108 | + * jq version 1.2 was released on Thu Dec 20 2012 |
| 109 | + * jq version 1.1 was released on Sun Oct 21 2012 |
| 110 | + * jq version 1.0 was released on Sun Oct 21 2012 |
| 111 | +
|
| 112 | +New features in 1.6 since 1.5: |
| 113 | +
|
| 114 | + - Destructuring Alternation |
| 115 | +
|
| 116 | + - New Builtins: |
| 117 | + - builtins/0 |
| 118 | + - stderr/0 |
| 119 | + - halt/0, halt_error/1 |
| 120 | + - isempty/1 |
| 121 | + - walk/1 |
| 122 | + - utf8bytelength/1 |
| 123 | + - localtime/0, strflocaltime/1 |
| 124 | + - SQL-style builtins |
| 125 | + - and more! |
| 126 | +
|
| 127 | + - Add support for ASAN and UBSAN |
| 128 | +
|
| 129 | + - Make it easier to use jq with shebangs (8f6f28c) |
| 130 | +
|
| 131 | + - Add $ENV builtin variable to access environment |
| 132 | +
|
| 133 | + - Add JQ_COLORS env var for configuring the output colors |
| 134 | +
|
| 135 | +New features in 1.5 since 1.4: |
| 136 | +
|
| 137 | + - regular expressions (with Oniguruma) |
| 138 | +
|
| 139 | + - a library/module system |
| 140 | +
|
| 141 | + - many new builtins |
| 142 | +
|
| 143 | + - datetime builtins |
| 144 | + - math builtins |
| 145 | + - regexp-related builtins |
| 146 | + - stream-related builtins (e.g., all/1, any/1) |
| 147 | + - minimal I/O builtins (`inputs`, `debug`) |
| 148 | +
|
| 149 | + - new syntactic features, including: |
| 150 | +
|
| 151 | + - destructuring (`. as [$first, $second] | ...`) |
| 152 | + - try/catch, generalized `?` operator, and label/break |
| 153 | + - `foreach` |
| 154 | + - multiple definitions of a function with different numbers of |
| 155 | + arguments |
| 156 | +
|
| 157 | + - command-line arguments |
| 158 | +
|
| 159 | + - --join-lines / -j for raw output |
| 160 | + - --argjson and --slurpfile |
| 161 | + - --tab and --indent |
| 162 | + - --stream (streaming JSON parser) |
| 163 | + - --seq (RFC7464 JSON text sequence) |
| 164 | + - --run-tests improvements |
| 165 | +
|
| 166 | + - optimizations: |
| 167 | +
|
| 168 | + - tail-call optimization |
| 169 | + - reduce and foreach no longer leak a reference to . |
| 170 | +
|
| 171 | +New features in 1.4 since 1.3: |
| 172 | +
|
| 173 | + - command-line arguments |
| 174 | +
|
| 175 | + - jq --arg-file variable file |
| 176 | + - jq --unbuffered |
| 177 | + - jq -e / --exit-status (set exit status based on outputs) |
| 178 | + - jq -S / --sort-keys (now jq no longer sorts object keys by |
| 179 | + default |
| 180 | +
|
| 181 | + - syntax |
| 182 | +
|
| 183 | + - .. -> like // in XPath (recursive traversal) |
| 184 | + - question mark (e.g., .a?) to suppress errors |
| 185 | + - ."foo" syntax (equivalent to .["foo"]) |
| 186 | + - better error handling for .foo |
| 187 | + - added % operator (modulo) |
| 188 | + - allow negation without requiring extra parenthesis |
| 189 | + - more function arguments (up to six) |
| 190 | +
|
| 191 | + - filters: |
| 192 | +
|
| 193 | + - any, all |
| 194 | + - iterables, arrays, objects, scalars, nulls, booleans, numbers, |
| 195 | + strings, values |
| 196 | +
|
| 197 | + - string built-ins: |
| 198 | +
|
| 199 | + - split |
| 200 | + - join (join an array of strings with a given separator string) |
| 201 | + - ltrimstr, rtrimstr |
| 202 | + - startswith, endswith |
| 203 | + - explode, implode |
| 204 | + - fromjson, tojson |
| 205 | + - index, rindex, indices |
| 206 | +
|
| 207 | + - math functions |
| 208 | +
|
| 209 | + - floor, sqrt, cbrt, etetera (depends on what's available from libm) |
| 210 | + |
| 211 | + - libjq -- a C API interface to jq's JSON representation and for |
| 212 | + running jq programs from C applications |
| 213 | +
|
0 commit comments