15 fprintf(stderr,
"Usage: schemavalidator schema.json < input.json\n");
24 FILE *fp = fopen(
argv[1],
"r");
26 printf(
"Schema file '%s' not found\n",
argv[1]);
31 if (
d.HasParseError()) {
32 fprintf(stderr,
"Schema file '%s' is not a valid JSON\n",
argv[1]);
33 fprintf(stderr,
"Error(offset %u): %s\n",
34 static_cast<unsigned>(
d.GetErrorOffset()),
51 fprintf(stderr,
"Input is not a valid JSON\n");
52 fprintf(stderr,
"Error(offset %u): %s\n",
59 printf(
"Input JSON is valid.\n");
63 printf(
"Input JSON is invalid.\n");
66 fprintf(stderr,
"Invalid schema: %s\n", sb.
GetString());
70 fprintf(stderr,
"Invalid document: %s\n", sb.
GetString());
75 fprintf(stderr,
"Error report:\n%s\n", sb.
GetString());
File byte stream for input using fread().
ParseResult Parse(InputStream &is, Handler &handler)
Parse JSON text.
ParseErrorCode GetParseErrorCode() const
Get the ParseErrorCode of last parsing.
size_t GetErrorOffset() const
Get the position of last parsing error in input, 0 otherwise.
ValueType & GetError()
Gets the error object.
PointerType GetInvalidSchemaPointer() const
Gets the JSON pointer pointed to the invalid schema.
virtual bool IsValid() const
Checks whether the current state is valid.
const Ch * GetInvalidSchemaKeyword() const
Gets the keyword of invalid schema.
PointerType GetInvalidDocumentPointer() const
Gets the JSON pointer pointed to the invalid value.
const Ch * GetString() const
Writer with indentation and spacing.
RAPIDJSON_NAMESPACE_BEGIN const RAPIDJSON_ERROR_CHARTYPE * GetParseError_En(ParseErrorCode parseErrorCode)
Maps error code of parsing into error message.
@ kParseErrorTermination
Parsing was terminated.