13 int main(
int argc,
char *argv[]) {
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]);
32 fprintf(stderr,
"Schema file '%s' is not a valid JSON\n", argv[1]);
33 fprintf(stderr,
"Error(offset %u): %s\n",
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());
ParseErrorCode GetParseError() const
Get the ParseErrorCode of last parsing.
virtual bool IsValid() const
Checks whether the current state is valid.
ValueType & GetError()
Gets the error object.
size_t GetErrorOffset() const
Get the position of last parsing error in input, 0 otherwise.
const Ch * GetInvalidSchemaKeyword() const
Gets the keyword of invalid schema.
ParseResult Parse(InputStream &is, Handler &handler)
Parse JSON text.
File byte stream for input using fread().
bool HasParseError() const
Whether a parse error has occurred in the last parsing.
PointerType GetInvalidDocumentPointer() const
Gets the JSON pointer pointed to the invalid value.
Writer with indentation and spacing.
int main(int argc, char *argv[])
RAPIDJSON_NAMESPACE_BEGIN const RAPIDJSON_ERROR_CHARTYPE * GetParseError_En(ParseErrorCode parseErrorCode)
Maps error code of parsing into error message.
ParseErrorCode GetParseErrorCode() const
Get the ParseErrorCode of last parsing.
const Ch * GetString() const
PointerType GetInvalidSchemaPointer() const
Gets the JSON pointer pointed to the invalid schema.
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with Encoding conversion)
size_t GetErrorOffset() const
Get the position of last parsing error in input, 0 otherwise.