JQ::Lite

🧩 JQ::Lite β€” Lightweight jq in Pure Perl

GitHub

JQ::Lite is a pure-Perl JSON query engine inspired by jq. It allows you to query and transform JSON using jq-like syntax β€” without external binaries.

✨ Highlights

πŸ’‘ Why Pure Perl?

Unlike the original jq written in C, JQ::Lite is implemented entirely in Perl.
This design choice brings several practical advantages:

🧩 Portability

No compilation, no shared libraries β€” it runs anywhere Perl runs.
Perfect for restricted, legacy, or air-gapped environments.

🧰 Extensibility

Add or customize jq-like functions directly in Perl.
Leverage CPAN modules (LWP, DBI, etc.) to integrate with APIs, databases, or filesystems.

🧱 Integration

Use it seamlessly inside Perl scripts:

use JQ::Lite;
my $jq = JQ::Lite->new;
say for $jq->run_query($json, '.users[].name');

No need to call external binaries or parse command output.

βš™οΈ Lightweight Installation

No XS/C libraries or make install required β€” just cpanm JQ::Lite or the portable installer. Ideal for CI/CD pipelines or user-level installations.

πŸ” Maintainability

Perl’s expressive syntax allows faster development and debugging. Community patches and feature extensions are easier than C-level contributions.

βš™οΈ Installation

πŸ›  From CPAN

cpanm JQ::Lite

🍺 Homebrew (macOS)

brew tap kawamurashingo/jq-lite
brew install --HEAD jq-lite

🐧 Portable (Linux/macOS)

curl -fsSL https://raw.githubusercontent.com/kawamurashingo/JQ-Lite/main/install.sh | bash

Installs to $HOME/.local/bin. Add to PATH if needed:

export PATH="$HOME/.local/bin:$PATH"

πŸš€ Usage

As a Perl module

use JQ::Lite;
my $jq = JQ::Lite->new;
my @names = $jq->run_query('{"users":[{"name":"Alice"}]}', '.users[].name');
print join("\n", @names);

As a CLI tool

jq-lite '.users[].name' users.json
jq-lite '.users[] | select(.age > 25)' users.json
jq-lite --yaml '.users[].name' users.yaml

πŸ’‘ Try interactive mode:

jq-lite users.json

🧱 Environment Support

| Environment | jq | jq-lite | | -------------------- | -- | ------- | | Legacy CentOS / RHEL | ❌ | βœ… | | Alpine Linux | ⚠️ | βœ… | | Air-gapped / Proxy | ❌ | βœ… | | No root privilege | ⚠️ | βœ… |

βœ… Runs on Perl β‰₯ 5.14, even on CentOS 6 or Debian 7 with perlbrew or local install.

πŸ” Example Queries

jq-lite '.users[] | select(.profile.active) | .name' users.json
jq-lite '.users | sort_by(.age) | map(.name) | join(", ")' users.json
jq-lite '.users[].nickname? // .name' users.json

🧠 More Functions

See the complete list in πŸ‘‰ FUNCTIONS.md or on MetaCPAN

πŸ‘€ Author

Shingo Kawamura πŸ“§ pannakoota1@gmail.com πŸ”— GitHub @kawamurashingo

πŸ“œ License

Same terms as Perl itself.