Compares two or more JSON files and detects which keys are missing.
npm install -g compare-json
When installed you can run the comparejson command from your command line.
For example:
$ comparejson ./test/fixture/*.json
For options, you can also run help $ comparejson --help
| Flag | Short Flag | Description |
|---|---|---|
| --help | Show help. | |
| --exit | -e | Exits the process with error code 1 when at least one error was found. |
| --separator | -s | Separates files in different comparison groups using a separator string.
For example, assume the files user-en.json, user-nl.json, register-en.json, register-nl.json; to split these files in two comparison groups "user" and "register" you can run comparejson -s="-" ./*.json. |
| --group-by | -g | Separates files in different comparison groups using a regular expression. Only files within the same group are compared to one another.
For example, assume the files user-en.json, user-nl.json, register-en.json, register-nl.json; to split these files in two comparison groups "user" and "register" you can run comparejson -g="(.+)\-.[^\/]+.*" ./*.json. Please note that this particular example can be achieved easier using the --separator option. |
| --ignore-ungrouped | -i | When using --group-by or --separator all files not matching any group will be ignored by default. To change this behaviour and group all unmatched groups in a single group use -i=false. |
| --suppress-errors | -se | Suppresses errors for files that match the given regex. The keys found in this file will be used as part of the comparison |