Validating a JSON file is easy. There are many good online ones, like http://jsonlint.com/. However, if you want to validate many files, it is cumbersome, or if you have sensitive data in your JSON file, you may not want to copy/paste that to a public site.
The solution is simple. Simply install a JSON validator / checker locally. And they also allow for “pretty printing” of your JSON too. There are a few ways to skin this cat.
Steps (jsonlint):
- Install NPM. Part of nodejs. Get it from http://nodejs.org/download/
- Get jsonlint from https://www.npmjs.org/package/jsonlint
- Reboot (if on Windows)
For multiple files, script it. E.g. on Windows use “for %i in (content\*.json) do jsonlint -q %i”
Steps (Cygwin):
- Make sure that Python is installed.
To run simply open a Cygwin prompt and type “cat FILE | python -mjson.tool”.
For multiple files, script it. E.g. in BASH “for FILE in content/*.json \n do \n cat $FILE | python -mjson.tool \n done”Thomas