ynqa / jnv Goto Github PK
View Code? Open in Web Editor NEWinteractive JSON filter using jq
License: MIT License
interactive JSON filter using jq
License: MIT License
If published as a Docker image it can be used easily without depending on cargo or homebrew
It would be nice to have those binaries available to download
Running the provided install instructions gives me an error:
cargo install jnv
Updating crates.io index
Downloaded jnv v0.1.0
Downloaded 1 crate (24.0 KB) in 0.11s
Installing jnv v0.1.0
Updating crates.io index
Downloaded autotools v0.2.6
Downloaded anstream v0.6.13
Downloaded autocfg v1.1.0
Downloaded equivalent v1.0.1
Downloaded anstyle-query v1.0.2
Downloaded anstyle-parse v0.2.3
Downloaded anstyle v1.0.6
Downloaded cfg-if v1.0.0
Downloaded lazy_static v1.4.0
Downloaded fastrand v2.0.1
Downloaded errno v0.3.8
Downloaded clap_lex v0.7.0
Downloaded bitflags v2.5.0
Downloaded gag v1.0.0
Downloaded colorchoice v1.0.0
Downloaded endian-type v0.1.2
Downloaded j9 v0.1.1
Downloaded anyhow v1.0.81
Downloaded either v1.10.0
Downloaded filedescriptor v0.8.2
Downloaded libloading v0.8.3
Downloaded clap_derive v4.5.3
Downloaded cexpr v0.6.0
Downloaded signal-hook-mio v0.2.3
Downloaded nibble_vec v0.1.0
Downloaded home v0.5.9
Downloaded lazycell v1.3.0
Downloaded itoa v1.0.10
Downloaded heck v0.5.0
Downloaded glob v0.3.1
Downloaded lock_api v0.4.11
Downloaded same-file v1.0.6
Downloaded rustc-hash v1.1.0
Downloaded thiserror v1.0.58
Downloaded thiserror-impl v1.0.58
Downloaded shlex v1.3.0
Downloaded utf8parse v0.2.1
Downloaded unicode-width v0.1.11
Downloaded which v4.4.2
Downloaded strsim v0.11.0
Downloaded quote v1.0.35
Downloaded scopeguard v1.2.0
Downloaded cc v1.0.90
Downloaded parking_lot_core v0.9.9
Downloaded clang-sys v1.7.0
Downloaded clap v4.5.3
Downloaded signal-hook-registry v1.4.1
Downloaded walkdir v2.5.0
Downloaded tempfile v3.10.1
Downloaded smallvec v1.13.1
Downloaded log v0.4.21
Downloaded parking_lot v0.12.1
Downloaded proc-macro2 v1.0.79
Downloaded aho-corasick v1.1.2
Downloaded signal-hook v0.3.17
Downloaded ryu v1.0.17
Downloaded prettyplease v0.2.16
Downloaded promkit v0.3.1
Downloaded unicode-ident v1.0.12
Downloaded serde v1.0.197
Downloaded indexmap v2.2.5
Downloaded minimal-lexical v0.2.1
Downloaded memchr v2.7.1
Downloaded mio v0.8.11
Downloaded nom v7.1.3
Downloaded crossterm v0.27.0
Downloaded hashbrown v0.14.3
Downloaded itertools v0.12.1
Downloaded clap_builder v4.5.2
Downloaded serde_json v1.0.114
Downloaded bindgen v0.69.4
Downloaded radix_trie v0.2.1
Downloaded regex v1.10.3
Downloaded syn v2.0.53
Downloaded regex-syntax v0.8.2
Downloaded rustix v0.38.31
Downloaded regex-automata v0.4.6
Downloaded libc v0.2.153
Downloaded linux-raw-sys v0.4.13
Downloaded j9-sys v0.1.1
Downloaded 80 crates (9.3 MB) in 2.86s (largest was `j9-sys` at 1.9 MB)
Compiling proc-macro2 v1.0.79
Compiling unicode-ident v1.0.12
Compiling libc v0.2.153
Compiling glob v0.3.1
Compiling anyhow v1.0.81
Compiling prettyplease v0.2.16
Compiling rustix v0.38.31
Compiling either v1.10.0
Compiling cfg-if v1.0.0
Compiling memchr v2.7.1
Compiling thiserror v1.0.58
Compiling minimal-lexical v0.2.1
Compiling linux-raw-sys v0.4.13
Compiling bitflags v2.5.0
Compiling regex-syntax v0.8.2
Compiling home v0.5.9
Compiling autocfg v1.1.0
Compiling bindgen v0.69.4
Compiling smallvec v1.13.1
Compiling same-file v1.0.6
Compiling lazycell v1.3.0
Compiling rustc-hash v1.1.0
Compiling libloading v0.8.3
Compiling parking_lot_core v0.9.9
Compiling cc v1.0.90
Compiling log v0.4.21
Compiling lazy_static v1.4.0
Compiling signal-hook v0.3.17
Compiling itertools v0.12.1
Compiling shlex v1.3.0
Compiling walkdir v2.5.0
Compiling scopeguard v1.2.0
Compiling serde v1.0.197
Compiling utf8parse v0.2.1
Compiling colorchoice v1.0.0
Compiling lock_api v0.4.11
Compiling anstyle-parse v0.2.3
Compiling serde_json v1.0.114
Compiling anstyle v1.0.6
Compiling anstyle-query v1.0.2
Compiling equivalent v1.0.1
Compiling hashbrown v0.14.3
Compiling nibble_vec v0.1.0
Compiling heck v0.5.0
Compiling clang-sys v1.7.0
Compiling endian-type v0.1.2
Compiling clap_lex v0.7.0
Compiling ryu v1.0.17
Compiling anstream v0.6.13
Compiling strsim v0.11.0
Compiling fastrand v2.0.1
Compiling itoa v1.0.10
Compiling radix_trie v0.2.1
Compiling nom v7.1.3
Compiling unicode-width v0.1.11
Compiling clap_builder v4.5.2
Compiling autotools v0.2.6
Compiling quote v1.0.35
Compiling syn v2.0.53
Compiling indexmap v2.2.5
Compiling signal-hook-registry v1.4.1
Compiling mio v0.8.11
Compiling regex-automata v0.4.6
Compiling parking_lot v0.12.1
Compiling signal-hook-mio v0.2.3
Compiling which v4.4.2
Compiling cexpr v0.6.0
Compiling tempfile v3.10.1
Compiling regex v1.10.3
Compiling thiserror-impl v1.0.58
Compiling clap_derive v4.5.3
Compiling filedescriptor v0.8.2
Compiling crossterm v0.27.0
Compiling gag v1.0.0
Compiling clap v4.5.3
Compiling promkit v0.3.1
Compiling j9-sys v0.1.1
The following warnings were emitted during compilation:
warning: [email protected]: Compiler version doesn't include clang or GCC: "cc" "--version"
warning: [email protected]: Compiler version doesn't include clang or GCC: "c++" "--version"
error: failed to run custom build command for `j9-sys v0.1.1`
Caused by:
process didn't exit successfully: `/tmp/cargo-installi3WdUy/release/build/j9-sys-12bea070e1c64770/build-script-build` (exit status: 101)
--- stdout
cargo:warning=Compiler version doesn't include clang or GCC: "cc" "--version"
cargo:warning=Compiler version doesn't include clang or GCC: "c++" "--version"
running: cd "/tmp/cargo-installi3WdUy/release/build/j9-sys-2575b3d26089796e/out/jq_build" && "sh" "-c" "exec \"$0\" \"$@\"" "autoreconf" "-i"
--- stderr
autoreconf: 1: exec: autoreconf: not found
thread 'main' panicked at /home/isaac/.cargo/registry/src/index.crates.io-6f17d22bba15001f/autotools-0.2.6/src/lib.rs:781:5:
command did not execute successfully, got: exit status: 127
build script failed, must exit now
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: failed to compile `jnv v0.1.0`, intermediate artifacts can be found at `/tmp/cargo-installi3WdUy`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.
the brew install command gives an error as well
brew install ynqa/tap/jnv
==> Auto-updating Homebrew...
Adjust how often this is run with HOMEBREW_AUTO_UPDATE_SECS or disable with
HOMEBREW_NO_AUTO_UPDATE. Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Error: formulae require at least a URL
Please report this issue:
https://docs.brew.sh/Troubleshooting
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:307:in `determine_active_spec'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formula.rb:238:in `initialize'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formulary.rb:527:in `new'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formulary.rb:527:in `get_formula'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formulary.rb:751:in `get_formula'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formulary.rb:964:in `factory'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cli/named_args.rb:126:in `block in load_formula_or_cask'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/api.rb:205:in `with_no_api_env_if_needed'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cli/named_args.rb:118:in `load_formula_or_cask'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cli/named_args.rb:83:in `block in to_formulae_and_casks'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cli/named_args.rb:81:in `each'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cli/named_args.rb:81:in `flat_map'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cli/named_args.rb:81:in `to_formulae_and_casks'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/install.rb:197:in `install'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:86:in `<main>'
I don't use brew often, and this is my first time using cargo, so apologies if its something obvious!
When I look at the demo.tape gif in the repo, there are newlines in the json and using jnv you can step through the data.
When I run a "kubectl get -ojson | jnv" I get everything on one long line. Not as usable. Am I missing some terminal settings, or is there something jnv mess up?
It would be nice if jnv supported sequences of json objects separate by newlines the way jq does:
{ "a": 123 }
{ "a": 123 }
Note: fx also supports this.
a=$(jnv a.json )
Error: The cursor position could not be read within a normal duration
How can I get the filter data as output or copy it?
On macOS, I frequently use Option+Arrow Keys to jump through text inputs one "word" at a time. This works in the native shell as well as most text inputs. Would it be possible to support this in jnv's query input?
Thanks for making this! It's a neat tool that I've enjoyed with the minimal usage I've had so far, and I hope it's been a fun project to work on.
echo '{ "items": [ {"foo": "bar" }, {"foo": "baz" } ] }' | jnv
.items[]
# enter tab nothing happen
# hope show the 'foo' to select
jnv 0.1.2
when I enter xterm -cm
and get a terminal without color (from what I understand of what the -cm
flags are doing) I see blinking during tab completion. I wonder why? Sorry my video is a bit zoomed strangely but will show you what I see. Cool tool and many thanks. My terminal colors are strange anyway so this isn't a big deal but wanted to report it and see if there is an easy fix.
cargo install jnv
It output error message like:
error: failed to run custom build command for j9-sys v0.1.2
...
error: failed to compile jnv v0.1.1
, intermediate artifacts can be found at /tmp/cargo-installtF2qom
.
I'd love to use jnv
with newline delimited json files as well. Right now, when I load an ndjson file, I get the following error:
$ jnv ncbi_dataset/data/data_report.jsonl
Error: trailing characters at line 2 column 1
jq
on the other hand has absolutely no issue with jsonl
files.
❯❯
)(Under investigation)
JQ has a neat mode --slurp
that reads a new-line delimited json into an array so that one can use the usual syntax on that sort of file. See for example: https://eureka.redwill.se/jq-slurp/
Would be cool if jnv
supported that.
jnv: /lib64/libc.so.6: version `GLIBC_2.29' not found (required by jnv)
jnv: /lib64/libm.so.6: version `GLIBC_2.29' not found (required by jnv)
On a AlmaLinux 8 box. This is because the latest the almalinux repos has is:
glibc-2.28-236.el8_9.12.i686 : The GNU libc libraries
Repo : baseos
Matched from:
Provide : libc.so.6
Hi there,
First off, I'd like to express my appreciation for the work you've put into this project! Muy Bueno!
However, I encountered a limitation that I believe could improve the user experience significantly if tackled.
While going through the documentation, I noticed there wasn't a mention of how to enable scrolling functionality. This feature becomes crucial when dealing with outputs that exceed the terminal's size, as users (like myself) would expect the ability to navigate through the text to inspect specific details more closely, before I choose to write a filter. (Yes, I know i can check the json before with like, less, but it is a bit tedious)
Could you provide guidance on enabling scrolling, or would it be possible to consider this as a feature request for future releases?
Thanks a mill!
It's a very cool tool, does it work on bash? or it depends on system(Linux/MacOS)?
At the time of v0.1.0, the author deemed it most appropriate to use the original jq.
However, managing C-related stuff during build time had to be undertaken, and this was underestimated at the release of v0.1.0. After actually releasing and taking a look the installation error issues that were raised, it became apparent that continuing to use jq might not be the best decision.
Then, there is a project in Rust called jaq, which is a jq-clone. I hope to discuss whether or not to replace jq with jaq, and whether it is feasible to do so.
Here's a rough outline of the pros and cons:
It would be nice if we add jnv to homebrew-core since they build the project in CI for all current macOS platforms.
Here is a formula I wrote. It should work but homebrew-core requires the repo to be >30 days old.
class Jnv < Formula
desc "JSON navigator and interactive filter leveraging jq"
homepage "https://github.com/ynqa/jnv"
url "https://github.com/ynqa/jnv/archive/refs/tags/v0.1.1.tar.gz"
sha256 "40fdb9de56d7ad55f7f3c52440ba7920f9aaffec07d59881b04e87a6facc5d28"
license "MIT"
head "https://github.com/ynqa/jnv.git", branch: "main"
livecheck do
url :stable
strategy :github_latest
end
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
depends_on "rust" => :build
def install
system "cargo", "install", *std_cargo_args
end
test do
assert_equal "jnv #{version}", shell_output("#{bin}/jnv --version").strip
end
end
It would be cool to be able to specify a default query for interactive searching:
$ cat data.json | jnv --default-query '.result.abc'
❯❯ .result.abc
...
This would make it easier when inspecting multiple similar json inputs to always land in the same entry and investigate interactively from there using jnv
instead of needing to type .result.abc
each time.
I love the idea of this tool, and the demo looks really cool too!
Installation worked flawlessly with cargo install jnv
, but when I fired it up on a real JSON I had looked at with jq
earlier, I noticed it was painfully slow, unusably slow, response times were on the order of 5-10 seconds after each key stroke.
Of course this is v0.1.0 - but just wanted to give feedback nonetheless from my real world test drive.
I'm on an M1 Pro with 32GB RAM which is fairly high end.
I tried reducing the display depth but that didn't help.
Partly personal preference, but would like the highlighted line to be lower down, and possibly fixed in place. So context before the line is visible as well as afterwards.
Now to brush on the rust so I can raise a PR :-)
The text is quite a bit too dark to be readable in "preview" mode, i.e. when tabbing through keys:
I don't have any visual impairment so if I struggle it's likely impossible to read for people who don't have perfect vision.
In particular the dim blue can't be read against the black background.
It seems that your terminal shows the blue a bit differently:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.