12 int main(
int argc,
char *argv[]) {
14 fprintf(stderr,
"Usage: schemavalidator schema.json < input.json\n");
23 FILE *fp = fopen(argv[1],
"r");
25 printf(
"Schema file '%s' not found\n", argv[1]);
31 fprintf(stderr,
"Schema file '%s' is not a valid JSON\n", argv[1]);
32 fprintf(stderr,
"Error(offset %u): %s\n",
50 fprintf(stderr,
"Input is not a valid JSON\n");
51 fprintf(stderr,
"Error(offset %u): %s\n",
58 printf(
"Input JSON is valid.\n");
62 printf(
"Input JSON is invalid.\n");
65 fprintf(stderr,
"Invalid schema: %s\n", sb.
GetString());
69 fprintf(stderr,
"Invalid document: %s\n", sb.
GetString());
ParseResult Parse(InputStream &is, Handler &handler)
Parse JSON text.
const Ch * GetString() const
ParseErrorCode GetParseErrorCode() const
Get the ParseErrorCode of last parsing.
ParseErrorCode GetParseError() const
Get the ParseErrorCode of last parsing.
PointerType GetInvalidSchemaPointer() const
Gets the JSON pointer pointed to the invalid schema.
int main(int argc, char *argv[])
PointerType GetInvalidDocumentPointer() const
Gets the JSON pointer pointed to the invalid value.
virtual bool IsValid() const
Checks whether the current state is valid.
File byte stream for input using fread().
const Ch * GetInvalidSchemaKeyword() const
Gets the keyword of invalid schema.
size_t GetErrorOffset() const
Get the position of last parsing error in input, 0 otherwise.
size_t GetErrorOffset() const
Get the position of last parsing error in input, 0 otherwise.
RAPIDJSON_NAMESPACE_BEGIN const RAPIDJSON_ERROR_CHARTYPE * GetParseError_En(ParseErrorCode parseErrorCode)
Maps error code of parsing into error message.
bool HasParseError() const
Whether a parse error has occured in the last parsing.
GenericDocument & ParseStream(InputStream &is)
Parse JSON text from an input stream (with Encoding conversion)