tree: 943c52e5ce8865769b6948807d43e7692ab93c57 [path history] [tgz]
  1. src/
  2. test/

JSON validator

The present tool verifies JSON files against schemas defined with JSON Schema.


json_validator [--allow_comments] <path to schema> <path to file to verify> [path to stamp file]

The third argument represents the path to a stamp file which gets updated when the tool runs successfully. This argument is mostly designed for integration with GN actions.

The --allow_comments flags enables parsing non-standard JSON files that contain C-style comments (/* block */ and // inline). The comments are ignored. This only applies to the file being verified -- the schema file may not contain comments even if this option is enabled.

Schema references

The schema passed to the tool may refer to other schema files. The tool will be able to locate schema references for schemas specified as paths relative to the folder containing the main schema.

For example, if the tool is given a schema /path/to/main_schema.json and that schema contains a reference to file:another/sub_schema.json#/definitions/foo, the tool will look for the second schema at path/to/another/sub_schema.json.

Paths to schemas may be specified as file:another/sub_schema.json or more simply another/sub_schema.json.