public function matchSchema($json, $schema)
    {
        $validator = new Validator();

        if (is_string($json)) {
            $json = $this->decode($json, TRUE);
        } elseif (is_array($json)) {
            $json = (object) $json;
        }

        if (is_string($schema)) {
            $schema = $this->decode($schema, TRUE);
        } elseif (is_array($schema)) {
            $schema = (object) $schema;
        }

        $validator->check($json, $schema);
        $this->lastSchemaErrors = $validator->getErrors();

        return $validator->isValid();
    }
public function matchSchema($json, $schema)
    {
        $validator = new Validator();

        if (is_string($json)) {
            $json = $this->decode($json, TRUE);
        } elseif (is_array($json)) {
            $json = (object) $json;
        }

        if (is_string($schema)) {
            $schema = $this->decode($schema, TRUE);
        } elseif (is_array($schema)) {
            $schema = (object) $schema;
        }

        $validator->check($json, $schema);
        $this->lastSchemaErrors = $validator->getErrors();

        return $validator->isValid();
    }
public function matchSchema ( $ json , $ schema ) { $ validator = new Validator ( ) ; if ( is_string ( $ json ) ) { $ json = $ this -> decode ( $ json , TRUE ) ; } elseif ( is_array ( $ json ) ) { $ json = ( object ) $ json ; } if ( is_string ( $ schema ) ) { $ schema = $ this -> decode ( $ schema , TRUE ) ; } elseif ( is_array ( $ schema ) ) { $ schema = ( object ) $ schema ; } $ validator -> check ( $ json , $ schema ) ; $ this -> lastSchemaErrors = $ validator -> getErrors ( ) ; return $ validator -> isValid ( ) ; }
Matches a JSON string or structure to a schema.

It would be lovely to be able to return an object containing both
the result and the errors wich would itself be castable to boolean,
but alas, this is not yet possible on PHP.
@param string $json
@param string $schema
@return boolean
@see http://json-schema.org/
Matches a JSON string or structure to a schema .