hyperion.ng
Public Member Functions | List of all members
QJsonSchemaChecker Class Reference

JsonSchemaChecker is a very basic implementation of json schema. More...

#include <QJsonSchemaChecker.h>

Public Member Functions

bool setSchema (const QJsonObject &schema)
 
QPair< bool, bool > validate (const QJsonObject &value, bool ignoreRequired=false)
 Validate a JSON structure. More...
 
QJsonObject getAutoCorrectedConfig (const QJsonObject &value, bool ignoreRequired=false)
 Auto correct a JSON structure. More...
 
const QStringList & getMessages () const
 

Detailed Description

JsonSchemaChecker is a very basic implementation of json schema.

The json schema definition draft can be found at http://tools.ietf.org/html/draft-zyp-json-schema-03

The following keywords are supported:

Member Function Documentation

§ getAutoCorrectedConfig()

QJsonObject QJsonSchemaChecker::getAutoCorrectedConfig ( const QJsonObject &  value,
bool  ignoreRequired = false 
)

Auto correct a JSON structure.

Parameters
valueThe JSON value to correct
ignoreRequiredIgnore the "required" keyword in hyperion schema. Default is false
Returns
The corrected JSON structure

§ getMessages()

const QStringList & QJsonSchemaChecker::getMessages ( ) const
Returns
A list of error messages

§ setSchema()

bool QJsonSchemaChecker::setSchema ( const QJsonObject &  schema)
Parameters
schemaThe schema to use
Returns
true upon succes

§ validate()

QPair< bool, bool > QJsonSchemaChecker::validate ( const QJsonObject &  value,
bool  ignoreRequired = false 
)

Validate a JSON structure.

Parameters
valueThe JSON value to check
ignoreRequiredIgnore the "required" keyword in hyperion schema. Default is false
Returns
The first boolean is true when the arguments is valid according to the schema. The second is true when the schema contains no errors
TODO: Check the Schema in SetSchema() function and remove the QPair result

The documentation for this class was generated from the following files: