Crates.io | jsonvalid |
lib.rs | jsonvalid |
version | 0.1.1 |
source | src |
created_at | 2018-02-20 11:08:30.198384 |
updated_at | 2018-02-20 12:07:36.84082 |
description | Validate JSON files for syntax mistakes using a static binary that can be easily distributed! |
homepage | |
repository | https://github.com/nathankleyn/jsonvalid |
max_upload_size | |
id | 52024 |
size | 22,526 |
Validate JSON files for syntax mistakes using a static binary that can be easily distributed!
You can easily install this using Cargo:
cargo install jsonvalid
Alternatively, you can download a pre-built binary of JSON Valid from the GitHub releases page. Make sure to pick the appropriate static binary for your architecture.
If an architecture of your choice is not available, you don't want to use cargo install
, or you want to compile the latest code, you can do a simple cargo build --release
in the cloned out version of this repository to get a binary (only stable Rust is required).
➜ jsonvalid --help
JSON Valid X.Y.Z
Nathan Kleyn <nathan@nathankleyn.com>
Checks whether JSON is valid and well-formed.
USAGE:
jsonvalid [FILE]...
FLAGS:
-h, --help Prints help information
-V, --version Prints version information
ARGS:
<FILE>... files to validate; if none are given, it will read from stdin instead
JSON Valid will accept input via STDIN, exiting silently if there are no errors:
➜ echo '{ "foo": "bar" }' | jsonvalid
➜ echo $?
0
If there is an error, you will see detailed information as to where it occurred:
➜ echo '{ "foo": "bar"' | jsonvalid
# => Error in JSON: EOF while parsing an object at line 2 column 0
➜ echo $?
1
We can also use files instead of STDIN:
➜ echo '{ "foo": "bar" }' > valid.json
➜ echo '{ "foo": "bar"' > invalid.json
If we pass a valid file, we see the same successful, silent exit:
➜ jsonvalid valid.json
➜ echo $?
0
Similarly, an invalid file shows us the cause:
➜ jsonvalid invalid.json
# => Error in file invalid.json: EOF while parsing an object at line 2 column 0
➜ echo $?
1
We can also pass many files. If any of the files is invalid, the whole command fails:
➜ jsonvalid valid.json invalid.json
# => Error in file invalid.json: EOF while parsing an object at line 2 column 0
➜ echo $?
1
I wanted a way to easily validate the well-formedness of JSON files without the following:
jq
, which fails silently with unbalanced braces in <= v1.5).jsonlint
, which is currently broken and unmaintained anyway!)Thus, JSON Valid was born!
Licensed under either of
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.