Commit Graph

359 Commits

Author SHA1 Message Date
Nicolas Williams b82c231900 Remove -i option (#704)
In-place editing should be implemented with builtins for file I/O.
2015-03-05 21:52:02 -06:00
Nicolas Williams 3d2ab93b11 Fix #705 (--argfile weirdness) 2015-02-18 18:38:11 -06:00
Kim Toms ca78a746e6 Enhance from_entries to better deal with Amazon AWS Tags 2015-02-10 08:33:56 -05:00
i 5389fdb651 readability
Easier to read dashes than hyphens imho.
2015-01-27 13:32:15 -05:00
Nicolas Williams d630597e87 Fix docs for split/0 2015-01-12 10:47:43 -06:00
Nicolas Williams ae7f8d6ab9 Further module system revamp (fix #659)
To import a module now use:

    # Import module.jq file:
    import "relative/path/to/module" as foo;

    # Use the module's defs as foo::<def-name>

To import a JSON file:

    # Read file.json:
    import "relative/path/to/file" as $foo;
    #
    # Use as $foo::foo

Using `-L` now drops the builtin library path and appends the requested
path to the empty array (or the result of an earlier `-L`).

Support for the `$JQ_LIBRARY_PATH` environment variable has been
removed.
2014-12-31 20:09:53 -06:00
Nicolas Williams 7dc34b92af Add label $name | EXP; fix break
This is to fix the problem where `break` is dynamic, not lexical.

With this it should be possible to do this sort of thing:

    label $break | inputs | if ... then $break|error else . end

This is a backwards-incompatible change for master, but the previous
`break` hadn't shipped yet.

Still needed:

 - testing
2014-12-30 11:42:45 -06:00
pkoppstein 752e00bc66 transpose/0 for possibly jagged matrices 2014-12-27 18:52:36 -06:00
pkoppstein 00f018a054 bsearch(x) (binary search): builtin.c (tested), with documentation and test case. Always yields an integer (even if input is unsorted); returns (-1 - ix) if x is not in input array. 2014-12-27 18:44:20 -06:00
pkoppstein 56344670f4 ascii_upcase/0 and ascii_downcase/0 2014-12-27 18:38:52 -06:00
Nicolas Williams 5df20f4954 Add debug builtin
And refactor setup of jv dump flags.
2014-12-27 18:25:34 -06:00
Nicolas Williams 5bfb9781f7 Add Streaming parser (--stream)
Streaming means that outputs are produced as soon as possible.  With the
`foreach` syntax one can write programs which reduce portions of the
streaming parse of a large input (reduce into proper JSON values, for
example), and discard the rest, processing incrementally.

This:

    $ jq -c --stream .

should produce the same output as this:

    $ jq -c '. as $dot | path(..) as $p | $dot | getpath($p) | [$p,.]'

The output of `jq --stream .` should be a sequence of`[[<path>],<leaf>]`
and `[[<path>]]` values.  The latter indicate that the array/object at
that path ended.

Scalars and empty arrays and objects are leaf values for this purpose.

For example, a truncated input produces a path as soon as possible, then
later the error:

    $ printf '[0,\n'|./jq -c --stream .
    [[0],0]
    parse error: Unfinished JSON term at EOF at line 3, column 0
    $
2014-12-26 23:05:56 -06:00
Nico Williams 25d4cbd1b3 Merge pull request #624 from Janrain-Colin/patch-1
Doc correction
2014-12-26 22:14:17 -06:00
Nico Williams 3234a7681e Merge pull request #366 from slapresta/inversed-contains
Added `in` command
2014-12-26 22:00:41 -06:00
Nico Williams 36077da66a Merge pull request #628 from slapresta/map-on-objects
Modify map\1 so that it works on objects
2014-12-26 21:50:11 -06:00
Nico Williams e0f9b6a5cd Merge pull request #651 from eiiches/fix-examples
Fix several errors in the manual
2014-12-24 11:29:29 -06:00
Nicolas Williams 0053aa868c Add @tsv; fix #645 2014-12-24 11:21:18 -06:00
Nicolas Williams 56ae88d9d5 Module search revamp for pkg managers
The search path listed in an import directive can now be an array.  The
top-level search path is appended.  Null and empty strings in the path
terminate any search.  The "." in "." and "./*" is replaced with the
directory containing the file doing the import (for command-line
programs this is the current directory, though that may be a bad idea).

No version numbers or anything of the sort are gratuitously added to the
search paths.

All this makes external package managers possible by allowing
dependencies to be installed local to dependents.
2014-12-24 02:31:51 -06:00
Santiago Lapresta 84d3203dd1 Define map_values 2014-12-22 23:05:35 +01:00
Santiago Lapresta a3234034b5 in is now inside, added in as inverse of has 2014-12-22 22:17:53 +01:00
Santiago Lapresta b748eae035 Added in command 2014-12-22 22:14:06 +01:00
Eiichi Sato a6656edc7c Fix examples in manual 2014-12-21 03:26:04 +09:00
Eiichi Sato b4a9ea56ae Fix indents in manual.yml 2014-12-21 03:24:45 +09:00
Eiichi Sato fdbc91e3c4 HTML-escape jq programs in manual 2014-12-21 03:24:41 +09:00
Eiichi Sato bd67bb8273 Fix examples in manual 2014-12-21 03:24:38 +09:00
Nico Williams 54a0470c42 Merge pull request #611 from StevenMaude/tutorial-typo-fixes
Fix typos in tutorial
2014-12-12 17:46:17 -06:00
Nicolas Williams be11b2768f Add until(cond; next); fix #639 2014-12-12 17:35:59 -06:00
Nicolas Williams 44c2382402 Add --argjson, fix #648 2014-12-12 16:40:07 -06:00
Colin von Heuring c6495f6632 fix typo in manual 2014-12-06 16:27:43 -08:00
Colin von Heuring 6c8882caf3 Doc correction 2014-11-23 11:37:50 -08:00
Steven Maude cb376b27f8 Fix typos in tutorial
parrent > parent, url > URL
2014-11-05 10:47:37 +00:00
Nicolas Williams 89791a000b Add support for JSON sequence MIME type
Per draft-ietf-json-text-sequence-07 (which soon will be published as an
RFC).
2014-10-12 08:44:40 -05:00
pkoppstein 85f0e30c81 fix sub (#586); add gsub/3; add transpose/0.
Signed-off-by: William Langford <wlangfor@gmail.com>
2014-10-06 21:32:07 -04:00
Nicolas Williams 1796a716ea Restore split/1; don't use regexp (fix #576) 2014-10-03 17:58:45 -05:00
Nicolas Williams 07d8d5c5ef Update docs about sort/group/min/max/unique 2014-10-03 17:58:44 -05:00
Nicolas Williams 4a57b84db0 to_entries should not sort keys (fix #561) 2014-09-30 21:52:30 -05:00
Nicolas Williams f8d9478517 Document module system
Fix #511.
2014-08-14 03:26:28 -05:00
Nicolas Williams 32c08d48f3 Add def f($arg): syntax (fix #524) 2014-08-08 19:16:01 -05:00
Nicolas Williams eb12f0358e Fix docs YAML (introduced in #432) 2014-08-08 18:01:42 -05:00
pkoppstein a696c6b551 regex filters (#432): scan, splits, split, sub, gsub 2014-08-08 17:00:14 -05:00
Nicolas Williams 2159f9f5e0 Document TCO a bit more 2014-08-05 01:15:33 -05:00
Nicolas Williams 2518b3a34f Fix docs (missing backquotes) 2014-08-05 01:15:33 -05:00
William Langford c3d6d5fd37 Merge pull request #523 from eproxus/patch-1
Add example of selecting object with keys
2014-08-05 00:50:21 -04:00
pkoppstein f8fed0f0bc Apply TCO to recurse/1, add recurse/2; tweak docs
Signed-off-by: Nicolas Williams <nico@cryptonector.com>
2014-08-04 21:11:01 -05:00
Adam Lindberg 89545ea9d0 Add example of selecting object with keys
It is not very straight forward how to select objects by their attributes from an array. This example provides the basic use case of how to select some objects based key values.
2014-08-01 12:13:35 +02:00
pkoppstein 53993a9942 Add capture; document regular expression filters
Fix #493.
2014-07-28 19:41:21 -05:00
Nicolas Williams e1b20b48f0 Add first, nth, last (fix #510) 2014-07-28 13:18:58 -05:00
Nicolas Williams 01fc8168e9 Add -i option to edit files in place (fix #105) 2014-07-20 00:11:23 -05:00
Simon Elsbrock 538e012e85 jq 1.4 is in Debian
jq 1.4 is in Debian, please see https://tracker.debian.org/pkg/jq
2014-07-14 11:24:47 +02:00
Marc Bruggmann 089041b090 Fix manual example for endswith. 2014-07-13 19:02:21 +02:00