Add tests for JSON warnings containing metadata.
Add documentation for --json-err flag and JSON error and warning formats.
Fix JSON format documentation.
Extracted common JSON warning test logic to #collect_json_warnings.
Small cleanups.
Merge branch 'eriwen-json-output' into json-output

Closes #854