Skip to content
Myr

Re-apply patch from ff8924ce16e58f to dev manual

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

authored by Aleksey Tsalolikhin · committed by William Langford · parent d57d973 · Browse files · 1 file+48 added−0 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+48 added−0 removed

  • other:+48 added−0 removed

1 file+48 added−0 removed

modified:docs/content/manual/manual.yml+48 added
302 unmodified lines
303 Since jq by default pretty-prints all output, this trivial304 program can be a useful way of formatting JSON output from,305 say, `curl`.306307 An important point about the identity filter is that it 308 guarantees to preserve the literal decimal representation 309 of values. This is particularly important when dealing with numbers 310 which can't be losslessly converted to an IEEE754 double precision 311 representation.312313 jq doesn't truncate the literal numbers to double unless there314 is a need to make arithmetic operations with the number.315 Comparisions are carried out over the untruncated big decimal 316 representation of the number.317318 jq will also try to maintain the original decimal precision of the provided319 number literal. See below for examples. 320321 examples:322 - program: '.'323 input: '"Hello, world!"'324 output: ['"Hello, world!"']325326 - program: '. | tojson'327 input: '12345678909876543212345'328 output: ['"12345678909876543212345"']329330 - program: 'map([., . == 1]) | tojson'331 input: '[1, 1.000, 1.0, 100e-2]'332 output: ['"[[1,true],[1.000,true],[1.0,true],[1.00,true]]"']333334 - program: '. as $big | [$big, $big + 1] | map(. > 10000000000000000000000000000000)'335 input: '10000000000000000000000000000001'336 output: ['[true, false]']337338 - title: "Object Identifier-Index: `.foo`, `.foo.bar`"339 body: |340341 The simplest *useful* filter is `.foo`. When given a
207 unmodified lines
549 values take an input and produce an output - `42` is a valid jq550 expression that takes an input, ignores it, and returns 42551 instead.552553 Numbers in jq are internally represented by their IEEE754 double 554 precision approximation. Any arithmetic operation with numbers, 555 whether they are literals or results of previous filters, will 556 produce a double precision floating point result.557558 However, when parsing a literal jq will store the original literal559 string. If no mutation is applied to this value then it will make560 to the output in its original form, even if conversion to double 561 would result in a loss. 562563 entries:564 - title: "Array construction: `[]`"565 body: |566
123 unmodified lines
690 etc.). However, jq never does implicit type conversions. If you691 try to add a string to an object you'll get an error message and692 no result.693694 Please note that all numbers are converted to IEEE754 double precision 695 floating point representation. Arithmetic and logical operators are working696 with these converted doubles. Results of all such operations are also limited 697 to the double precision. 698699 The only exception to this behaviour of number is a snapshot of original number 700 literal. When a number which originally was provided as a literal is never701 mutated until the end of the program then it is printed to the output in its 702 original literal form. This also includes cases when the original literal 703 would be truncated when converted to the IEEE754 double precision floating point704 number.705706 entries:707 - title: "Addition: `+`"708 body: |709
2655 unmodified lines