Anyone who edits Dorico JSON files (such as the keycommands file, or SMuFL metadata) may be interested in this little python command to validate and indent (“prettify”) JSON files. On the Mac, it’s part of the system python installation.
python -m json.tool inputfile > outputfile
If you’re using BBEdit as your text editor (and why wouldn’t you? †) then you can create a “Text Filter” that applies this directly to open documents.
- Locate the folder for saved Text Filters.
Create a small text file containing the following code, and save it as JSON Verify.sh, or some similar name.
#!/bin/sh python -m json.tool
Then you can verify and indent any open JSON file from the Text > Apply Text Filter menu.
If there are any errors in your JSON file, BBEdit will create a new document window with the error message. If not, your JSON file will just be indented correctly.
† “Rhetorical question.”