Try jsonlint
:
sudo apt install jsonlint
The basic usage syntax is
jsonlint YOUR-FILE.JSON
You find its manual by typing man jsonlint
or visiting its online manpage:
An excerpt:
NAME
jsonlint - A JSON syntax validator and formatter tool
SYNOPSIS
jsonlint [-v][-s|-S][-f|-F][-ecodec]inputfile.json...
[...]
OPTIONS
The return status will be 0 if the file is legal JSON, or non-zero
otherwise. Use -v to see the warning details.
[...]
-v, --verbose
Show details of lint checking
-s, --strict
Be strict in what is considered legal JSON (the default)
-S, --nonstrict
Be loose in what is considered legal JSON
-f, --format
Reformat the JSON (if legal) to stdout
[...]
So you can see whether your JSON is valid by checking the return code of jsonlint
. You can see it by running echo $?
right afterwards (0=OK, 1=invalid), or by evaluating it using &&
, ||
or if
.