百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
X

xq

> 编程语言
开源

jq 的纯 Rust 实现

400 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

jq 的纯 Rust 实现

XQ

JQ reimplemented purely in Rust.

Caution

This program is under development. You probably want to use the original implementation of jq, or pure Go implementation of it called gojq built by itchyny instead, or another Rust implementation called jaq.

Current state

  • Most of the jq components that require syntactical support are, hmm, implemented and tested against queries taken from the jq user manual. Exceptions are imports and module headers.
  • Many builtin functions are missing, include those require intrinsic implementation.
  • Need more unit tests. Most of the CLI options are missing.
  • JSON and YAML formats are supported.

Goals

  • Learn jq.

Ideas

  • Since we use serde to deserialize input / serialize output, we should be able to support any format which has serde implementation (and has multi-document support) without too much effort, except those require scheme (protobuf, thrift, etc.).

  • As a library, we should be able to make anything that implements Serialize as the input type, and anything implements Deserialize as the output type. So in theory, we should be able to write a library that can handle following;

    rust
    #[derive(Serialize)]
    struct GitHubRepo {
        user_name: String,
        repo_name: String,
        stars: usize,
    }
    #[derive(Deserialize)]
    struct User {
        name: String,
        total_stars: usize,
    }
    let repos: Vec = fetch_repos();
    let users: Vec = xq::somefunction_slurp(repos, r#"
        group_by(.user_name)[]
        | { name: .[0].user_name, total_stars: ([.[].stars] | add) }
    "#).collect();

    I mean, it's not something that one should really use. It's just something possible and interesting... isn't it?

Install and run

Are you sure you want to use this??? It's not a daily-usable stage. Though if you want to try, you can install it via

bash
$ cargo install xq
$ cat whatever.json | xq 'query goes here'

. If you'd rather want to download a pre-built binary, either download it manually from the latest release, or use cargo-binstall. Either way, the license texts of the dependencies are in about.html file in the downloaded archive.

You can also clone this repository to your local and run

bash
$ cargo install --path path-to-cloned-dir
$ cat whatever.json | xq 'query goes here'

. Alternatively,

bash
$ cat whatever.json | cargo run -- 'query goes here'

in the cloned directory to try out them without installing.

Uninstall

bash
$ cargo uninstall xq

if you've installed via cargo install. Also remove the cloned directory if you've cloned the repository.

Publish new version

Note for myself.

bash
$ git switch master                 # make sure you're on the master branch
$ cargo release patch               # to dry-run the release
$ cargo release patch --execute     # to actually execute the release

Pass --workspace to publish workspace members as well.

Acknowledgements

  • Although this isn't a direct translation at all, I referred to jq built by Stephen Dolan and gojq built by itchyny. Thank you for the interesting product!

Credits

  • Test cases in tests/from_manual are taken from the jq user manual, distributed under CC BY 3.0, Copyright (C) 2012 Stephen Dolan. Please refer to mod.rs there for more detail.

Author

Mi_Sawa

LICENSE

MIT. Please refer to LICENSE file.

Issues· 14 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Rust

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言