Expand description
The jsonic command as a library: read relaxed JSON from arguments,
files or standard input, parse it with
tabnas-jsonic, merge the results
and print standard JSON.
This is the Rust port of the canonical TypeScript implementation in
ts/src/jsonic-cli.ts; the TypeScript version is authoritative and
this crate tracks it. The Go port is in go/.
The crate is a library plus a thin src/bin/jsonic.rs launcher, so
the command can be driven in process:
let argv: Vec<String> = ["jsonic", "a:b:1", "a:c:2"]
.iter()
.map(|s| s.to_string())
.collect();
let mut out: Vec<u8> = Vec::new();
let code = tabnas_jsonic_cli::run(
&argv,
&mut std::io::empty(),
&mut out,
&mut std::io::sink(),
);
assert_eq!(code, 0);
assert_eq!(String::from_utf8(out).unwrap(), "{\"a\":{\"b\":1,\"c\":2}}\n");Re-exports§
pub use cli::capture;pub use cli::run;pub use cli::run_with_plugins;pub use cli::Captured;pub use registry::plugins;pub use registry::register_plugin;
Modules§
- cli
- The command itself: argument parsing, option, meta and plugin wiring,
source merging and serialization. The port of
ts/src/jsonic-cli.tsand ofgo/cli/run.go. - registry
- The compiled-in plugin registry behind
-p/--plugin. The port ofgo/cli/registry.go.
Constants§
- VERSION
- This crate’s version. It MUST equal
ts/package.json“version” and theversioninCargo.toml: the release orchestrator rewrites all of them, andtests/version_test.rsfails the build if they drift. MirrorsVERSIONints/src/jsonic-cli.tsandconst VERSIONingo/cmd/jsonic/main.go.