# ðŸ§Đ JQ::Lite — Lightweight jq in Pure Perl ![JQ::Lite](./images/JQ_Lite_sm.png) [![MetaCPAN](https://img.shields.io/cpan/v/JQ-Lite.svg)](https://metacpan.org/release/JQ-Lite) [![Alpine Linux](https://img.shields.io/badge/Alpine-Linux%20community-0D597F?logo=alpinelinux\&logoColor=white)](https://pkgs.alpinelinux.org/package/edge/community/x86_64/jq-lite) [![Perl](https://img.shields.io/badge/Perl-5.14%2B-39457E?logo=perl\&logoColor=white)](https://www.perl.org/) 🌐 [Project homepage](https://kawamurashingo.github.io/JQ-Lite/index-en.html) --- ## âœĻ What is JQ::Lite? **JQ::Lite** is a **pure-Perl JSON query engine** inspired by [`jq`](https://stedolan.github.io/jq/). It lets you **query and transform JSON using jq-like syntax** — **without external binaries, native libraries, or compilation**. > ✅ **Official Alpine Linux package** > > ```bash > apk add jq-lite > ``` JQ::Lite is designed for **minimal environments** such as: * Alpine Linux * containers & CI pipelines * legacy / restricted / air-gapped systems where **simplicity, readability, and low dependency footprint** matter. --- ## 🚀 Why jq-lite (in one glance) * ðŸŠķ **Pure Perl** — no XS, no C, no shared libraries * 🔍 **jq-style filters**: `.users[].name`, `select(...)`, `map(...)` * ðŸ”Ē **Arithmetic & conditionals**: `if ... then ... else ... end` * 🔧 **CLI tool**: `jq-lite` * `--null-input`, `--slurp`, `--from-file` * `--yaml`, `--arg`, `--argjson` * 📊 **100+ built-in jq functions** → see [`FUNCTIONS.md`](FUNCTIONS.md) * ðŸ’ŧ **Interactive mode** for exploring JSON * 🧰 **JSON & YAML input** * 🌐 **Runs almost anywhere Perl runs** → even legacy or air-gapped systems → see [`VISION.md`](VISION.md) --- ## ⚡ Quick Start (CLI) ```bash jq-lite '.users[].name' users.json jq-lite '.users[] | select(.age > 25)' users.json jq-lite --yaml '.users[].name' users.yaml ``` Interactive exploration: ```bash jq-lite users.json ``` --- ## ðŸ§ą Environment Support | Environment | jq | jq-lite | | -------------------- | -- | ------- | | Legacy CentOS / RHEL | ❌ | ✅ | | Alpine Linux | ⚠ïļ | ✅ | | Air-gapped systems | ❌ | ✅ | | No root privilege | ⚠ïļ | ✅ | ✅ **Runs on Perl â‰Ĩ 5.14** (e.g. CentOS 6, Debian 7 via `perlbrew` or local install) --- ## ðŸ’Ą Why Pure Perl? ### ðŸ§Đ Portability No compilation, no shared libraries. If Perl runs, jq-lite runs. Perfect for: * minimal containers * legacy servers * restricted or offline environments --- ### 🧰 Extensibility Extend jq-like behavior **directly in Perl**. You can integrate CPAN modules such as: * `LWP` (HTTP / APIs) * `DBI` (databases) * filesystem or OS tools --- ### ðŸ§ą Seamless Perl Integration ```perl use JQ::Lite; my $jq = JQ::Lite->new; say for $jq->run_query($json, '.users[].name'); ``` No external command calls. No parsing of CLI output. --- ### ⚙ïļ Lightweight Installation * No XS / C toolchain * No system-wide install required * Ideal for CI/CD or user-local installs --- ### 🔍 Maintainability * Faster iteration than C-based jq * Easier debugging * Community contributions are simpler --- ## ⚙ïļ Installation ### 🛠 From CPAN ```bash cpanm JQ::Lite ``` --- ### 🐧 Alpine Linux (Official) ```bash apk add jq-lite ``` --- ### 🍚 Homebrew (macOS) ```bash brew tap kawamurashingo/jq-lite brew install --HEAD jq-lite ``` --- ## ðŸģ Containers (Recommended) **Alpine-based image** ```dockerfile FROM alpine RUN apk add --no-cache jq-lite ``` jq-lite is ideal as a **container-standard JSON tool**: * tiny footprint * predictable behavior * no native dependencies --- ## 🐧 Portable Installer (Online → Offline) For **air-gapped or offline systems**: 1. **Download (on connected machine)** ```bash ./download.sh [-v ] [-o /path/to/usb] ``` 2. **Transfer** `JQ-Lite-.tar.gz` 3. **Install** ```bash ./install.sh [-p ] [--skip-tests] JQ-Lite-.tar.gz ``` Default: ```bash $HOME/.local ``` Environment setup: ```bash export PATH="$HOME/.local/bin:$PATH" export PERL5LIB="$HOME/.local/lib/perl5/site_perl:$PERL5LIB" ``` --- ## 🊟 Windows (PowerShell) ```powershell .\install-jq-lite.ps1 [-Prefix ] [--SkipTests] JQ-Lite-.tar.gz ``` Verify: ```powershell jq-lite -v ``` --- ## 🔍 Example Queries ```bash 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 ``` --- ## 📚 Documentation * 📘 **Functions**: [`FUNCTIONS.md`](FUNCTIONS.md) * 🧭 **Vision & portability**: [`VISION.md`](VISION.md) * ðŸ“Ķ **MetaCPAN**: [https://metacpan.org/pod/JQ::Lite](https://metacpan.org/pod/JQ::Lite) --- ## ðŸ‘Ī Author **Shingo Kawamura (川村慎åū)** 📧 [pannakoota1@gmail.com](mailto:pannakoota1@gmail.com) --- ## 📜 License Same terms as Perl itself.