https://github.com/s-k2/yamlq
yamlq - jq modified to parse and output YAML. Available as a single, static-linked binary
https://github.com/s-k2/yamlq
cli jq yaml
Last synced: 13 days ago
JSON representation
yamlq - jq modified to parse and output YAML. Available as a single, static-linked binary
- Host: GitHub
- URL: https://github.com/s-k2/yamlq
- Owner: s-k2
- License: other
- Created: 2025-11-22T20:09:27.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2025-11-22T20:13:01.000Z (7 months ago)
- Last Synced: 2025-11-22T21:14:33.455Z (7 months ago)
- Topics: cli, jq, yaml
- Language: C
- Homepage:
- Size: 15.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# yamlq
yamlq is a tool for processing YAML inputs by applying a specified filter to the input data and producing the filter's results as YAML or JSON on standard output.
It uses jq code for almost everything except parsing and output generation. This means you can use the full range of jq's filtering capabilities with YAML files.
Unlike yq, yamlq is not implemented as a preprocessor for jq. Instead, it is a standalone C program that can be built statically. (This was the original motivation for creating it: I needed a yq-like tool in a minimal environment where Python was not available.)
## Limitations
- no support for YAML anchors and aliases
- no `fromyaml`/`toyaml` builtin to parse and dump YAML from strings
- no `--argyaml` command-line parameter
- yamlq always applies the fix for [GHSA-f946-j5j2-4w5m](https://github.com/jqlang/jq/security/advisories/GHSA-f946-j5j2-4w5m), this makes libonig a hard requirement
## Versioning
Whenever a new version of jq is released, yamlq will be updated as soon as possible. Because most of the code is shared with jq, its major/minor/patch version will also be used for yamlq.
When a new version of libyaml is released, the submodule will be updated as well. This will be reflected with an added/incremented fourth number in the version string.
Development builds (untagged commits) will report the short commit id as version number.
## Static Download
For every new version of yamlq, static binaries for `linux-amd64`, `linux-arm64` and `windows-amd64` will be available for download through Github Releases.
## Building
### Requirements
You need to install:
- a C99 compatible compiler (`gcc` and `clang` tested)
- `git` (to checkout submodules)
- `make`
- `patch`
- `awk`
- `sh`
Linking aginst your system's `libyaml`, `libjq` and `libonig` (dependency of jq) requires to install the corresponding development packages:
- Debian/Ubuntu: `sudo apt-get install libyaml-dev libjq-dev libonig-dev`
- Alpine: `apk add yaml-dev jq-dev oniguruma-dev`
- OpenSuse: `sudo zypper install libyaml-devel libjq-devel oniguruma-devel`
- Fedora: `dnf install libyaml-devel jq-devel oniguruma-devel`
For static builds, all dependencies will be downloaded and build automatically.
### Build and Install
If `libyaml`, `libjq` and `libonig` are available on your system, prefer building dynamically against those libraries. This ensures you benefit from your distribution's security updates. To build and install dynamically, run:
make
sudo make install
In case you need a static build with no runtime dependencies:
make getdeps
make static
sudo make install-static
You can use the CC make variable to change the compiler, e.g. to to build against musl libc:
make getdeps
make CC=musl-gcc static
sudo make install-static
The following two non-standard variables (additional configure-script parameters and OS-specific linker parameters for the final target only) are helpful for cross-compiling:
make getdeps
make CC=x86_64-w64-mingw32-gcc-posix CONFIGURE_FLAGS=--host=x86_64-w64-mingw32 LDFLAGS_OS="-municode -lshlwapi" static
Building requires internet connectivity to checkout git submodules (jq in any case, libyaml for a static build) to succeed. If you don't do this explicitly, it will be done automatically during the make step.