tree: c4e30494816b023447592da433b02a945dd619be [path history] [tgz]
  1. test/
  2. BUILD.gn
  3. main.cc
  4. README.md
build/tools/json_validator/README.md

JSON validator

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

Usage

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.