Exit code is 0 even if there is a mismatch.
$ json_diff d '{} ' ' {}' ; echo $?
No mismatch was found.
0
$ json_diff d '[] ' ' {}' ; echo $?
Mismatch at root.
0
Mismatch in the input json does not necessarily mean a failure for the tool itself.
Frankly, I am not convinced that the tool needs to return a non-zero exit code if the inputs don't match. Can you help me with your use case?
Typically comparison tools (e.g. diff, cmp) return non-zero exit code to mean "mismatch" and zero code to mean "no differences".
Failure for the tool itself is typically signaled by the non-zero non-one exit code, e.g. "2".
Exit code distinction is typically needed for comparting JSONs noninteractively. json_diff's comparison ignores whitespace and order of keys, which is tricky to attain in Bash without using additional tools.
Okay, yeah that makes sense.