JSON Valid Build Status Crates.io Version Of jsonvalid

Validate JSON files for syntax mistakes using a static binary that can be easily distributed!

Install

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).

Usage

``` ➜ jsonvalid --help JSON Valid 0.1.0 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: ... files to validate; if none are given, it will read from stdin instead ```

Examples

Using STDIN

JSON Valid will accept input via STDIN, exiting silently if there are no errors:

sh ➜ echo '{ "foo": "bar" }' | jsonvalid ➜ echo $? 0

If there is an error, you will see detailed information as to where it occurred:

```sh ➜ echo '{ "foo": "bar"' | jsonvalid

=> Error in JSON: EOF while parsing an object at line 2 column 0

➜ echo $? 1 ```

Using paths to files

We can also use files instead of STDIN:

sh ➜ echo '{ "foo": "bar" }' > valid.json ➜ echo '{ "foo": "bar"' > invalid.json

If we pass a valid file, we see the same successful, silent exit:

sh ➜ jsonvalid valid.json ➜ echo $? 0

Similarly, an invalid file shows us the cause:

```sh ➜ 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:

```sh ➜ jsonvalid valid.json invalid.json

=> Error in file invalid.json: EOF while parsing an object at line 2 column 0

➜ echo $? 1 ```

Background

I wanted a way to easily validate the well-formedness of JSON files without the following:

Thus, JSON Valid was born!

License

Licensed under either of

at your option.

Contribution

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.