jaq

A jq clone focussed on correctness, speed, and simplicity

MIT License

Downloads
84
Stars
2.5K
Committers
8

Bot releases are hidden (Show)

jaq - 1.0 beta

Published by 01mf02 about 1 year ago

This release includes a large number of new filters, mostly for:

Furthermore, it adds support for the try f catch g syntax (@kklingenberg, https://github.com/01mf02/jaq/pull/100), and strings can now be multiplied with integers to repeat them (@nouritsu, https://github.com/01mf02/jaq/pull/86).

The CLI supports the option --nul-output (@baod-rate, https://github.com/01mf02/jaq/pull/91) and matches jq’s exit code with --exit-status when there is no output (@baod-rate, https://github.com/01mf02/jaq/pull/92).

Under the hood, the API has changed considerably in order to accommodate for the changes implied by native filters. Most notably, the jaq-interpret crate (containing the interpreter, i.e. the heart of jaq) was split off from jaq-core, and the jaq-syn crate (containing only data types for the syntax) was split off from jaq-parse.

Thanks again to @baod-rate and @kklingenberg for their tremendous efforts!

New Contributors

Full Changelog: https://github.com/01mf02/jaq/compare/v1.0.0-alpha...v1.0.0-beta

jaq - 0.10.1

Published by 01mf02 about 1 year ago

This release fixes a critical bug that can occur when binding multiple variables. Furthermore, it uses a newer version of the regex crate to allow for a simpler installation.

Full Changelog: https://github.com/01mf02/jaq/compare/v0.10.0...v0.10.1

jaq - 1.0 alpha

Published by 01mf02 over 1 year ago

This release adds a lot of new features to jaq:

  • Recursive & nested functions: see the README for restrictions of recursive functions
  • Variable arguments: def foo($v; f): ...
  • Variables bound via command-line arguments (--arg) can be referred to from definitions now
  • New filters: walk(f), group_by(f), unique, unique_by(f), paths
  • Tests (--run-tests)

Thanks are due especially to @passcod for having implemented native filters. Users that use jaq as part of their own programs via the API can now implement filters as Rust functions and expose them to jaq. The API is still subject to change, see https://github.com/01mf02/jaq/pull/70.

Given the extent of these new features, I think that the time is ripe for a 1.0 release.
However, this is an alpha release because especially recursive/nested functions have not yet received the amount of testing that I would expect from a 1.0 release.
As I will be going this week on a cycling trip that will last about two months, I will not be available during this time to address issues myself. However, it is my hope that this time allows users to test the new functions and to report issues (and in the optimal case submit PRs to fix the problems), in order to allow for a more polished 1.0 release later.

New Contributors

Full Changelog: https://github.com/01mf02/jaq/compare/v0.10.0...v1.0.0-alpha

jaq - 0.10.0

Published by 01mf02 over 1 year ago

jaq is a jq clone with a focus on correctness, speed, and simplicity.
jaq 0.10.0 improves JSON parsing speed, supports regular expression filters and walk(f), and improves compatibility of foreach syntax and arguments handling.

Details:

  • JSON parsing: This release parses JSON using the new hifijson crate instead of serde_json.
    This increases JSON parsing performance, in one benchmark by up to 87% compared to jaq 0.9.0 and by 68% compared to jq.
  • Regular expressions: The filters test, scan, match, capture, splits, sub, gsub are now supported.
    Note that for named capture groups, the syntax (?<name>exp) is not supported when installing jaq by cargo install jaq;
    however, it is supported when installing jaq using cargo build, cargo install --path jaq or cargo install --git https://github.com/01mf02/jaq.
    This is because the underlying crate for parsing regular expressions, regex-syntax, does not support the (?<name>exp) syntax at the time of writing, so jaq currently uses a patched version of this crate, which is however not considered by cargo install jaq. In the future, the (?<name>exp) syntax is likely to be included in regex-syntax, which will make the (?<name>exp) syntax available also when installing jaq via cargo install jaq.
  • foreach, for: In jq 0.9, the semantics of foreach xs as $x (init; f) were changed such that it yielded the output of init, unlike jq. Following some discussion, the suggestion by @pkoppstein was implemented that restored the previous semantics of foreach, while introducing a new filter for xs as $x (init; f) that yields the output of init. More information can be found in the README.
  • Arguments handling: The --slurpfile and --rawfile options are now supported. Furthermore, arguments (such as passed by --arg a b) are now bound to $ARGS.

New Contributors

Full Changelog: https://github.com/01mf02/jaq/compare/v0.9.0...v0.10.0

jaq - 0.9.0

Published by 01mf02 almost 2 years ago

This release greatly improves performance of file reading by memory mapping. On one benchmark, for example, this change decreased runtime by about 27%. Pass input files as arguments to profit from this; i.e., use jaq 'filter' file.json instead of jaq 'filter' <file.json.

Several filters now behave more like in jq, for example assignment (=) and arithmetic update-assignment (+=, -=, ...).
Updates using f as $x | g or if f then g else h on the left-hand side are now evaluated correctly if f yields multiple values.
recurse, reduce, and foreach are now evaluated more lazily.

BREAKING CHANGE: foreach xs as $x(init; f) does now also output the outputs of init, and the syntax foreach xs as $x(init; f; proj) is not supported anymore. This makes the behaviour of foreach easier to describe and reason about, greatly simplifies the implementation and makes foreach behave more like reduce. See the README for details.

Users of jaq-core (the library powering jaq) might be happy to know that Filters are now Send and Sync. That means that it is now possible to execute a filter on multiple threads, processing multiple values in parallel. The jaq application itself does not make use of this (yet).

Full Changelog: https://github.com/01mf02/jaq/compare/v0.8.2...v0.9.0

jaq - 0.8.2

Published by 01mf02 about 2 years ago

This release adds the --raw-input / -R command-line option to jaq.
This is particularly useful to try the newly included Brainfuck interpreter (based on @itchyny's work) in examples/bf.jq. :)

Under the hood, jaq tries to avoid more clones when destructuring or updating arrays or objects.
For example, this makes [range(1000000) | [.] | .[]] | length about 6% faster.

Furthermore, expressions such as f[], which consist of some filter directly followed by a path, are now evaluated differently.
In particular, f is now evaluated lazily, whereas before, it was evaluated strictly.
This makes it possible to write a Fibonacci sequence generator as

 [0,1] | recurse([.[1], add])[0]

which previously would not have terminated.

Full Changelog: https://github.com/01mf02/jaq/compare/v0.8.1...v0.8.2

jaq - 0.8.1

Published by 01mf02 about 2 years ago

The main feature of this release is greatly improved parsing speed (012c9c58a35ee6b41fdca691f74fef5571493074).

Apart from this, there are three new filters suggested by @pkoppstein, namely debug, finites, and normals.
Furthermore, the performance of join has increased vastly.
Last but not least, the command-line interface has been updated to use Clap 4.

Full Changelog: https://github.com/01mf02/jaq/compare/v0.8.0...v0.8.1

jaq - 0.8.0

Published by 01mf02 about 2 years ago

What's Changed

The largest addition in this release is support for complex assignments: Previously, the left-hand side of assignments in jaq were restricted to simple path expressions, such as .[], .a. Now, jaq also supports assignments with more general left-hand sides, such as if .. then .. else .. end, recurse(..) and several others. This enables filters such as (.posts[] | select(.author == "stedolan") | .comments) |= . + ["terrible."] (taken from the jq manual --- I do not have such strong feelings towards Stephen Dolan's posts ^^).

This release also adds support for several new filters:

  • inputs, input: These filters make it now possible to process input lazily with state. This effectively makes jaq an impure programming language --- but impurity is restricted to modifying the stream of input values.
  • foreach xs as $x (init; update): This is a powerful tool, in particular in conjunction with inputs. For example, foreach inputs as $x (null; .+$x) builds a cumulative sum of the input elements, lazily.
  • ..: shorthand for recurse(.[]?)
  • while, until: thanks to @capezotte

Smaller changes include:

  • Configurable color usage via --color
  • Escaped characters in strings: It is now possible to write something like "\"".
  • Increased compatibility with jq: thanks to @itchyny for finding several places where jq and jaq diverged
  • Homebrew installation, thanks to @chenrui333

Full Changelog: https://github.com/01mf02/jaq/compare/v0.7.0...v0.8.0

jaq - 0.7.0

Published by 01mf02 over 2 years ago

What's Changed

This version adds a bunch of new command-line options:

  • -c / --compact: output JSON compactly (thanks to @alex-ozdemir!)
  • -i / --in-place: replace input files by their output
  • --arg: set contents of variables from the command-line
  • JSON input files can be passed as arguments

Furthermore, the try operator (?) is now supported. In a nutshell, f? yields those values for which f does not return an error.

New Contributors

Full Changelog: https://github.com/01mf02/jaq/compare/v0.6.0...v0.7.0