Skip to content

Update README.md #309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@ See [json-schema](http://json-schema.org/) for more details.
#### [`Composer`](https://github.com/composer/composer) (*will use the Composer ClassLoader*)

$ wget http://getcomposer.org/composer.phar
$ php composer.phar require justinrainbow/json-schema:~2.0
$ php composer.phar require --no-update justinrainbow/json-schema
$ composer.phar update

## Usage

```php
<?php

$data = json_decode(file_get_contents('data.json'));
$data = json_decode(file_get_contents('data.json')); //NOTE: this needs to be an object, not an array!

// Validate
$validator = new JsonSchema\Validator;
$validator->check($data, (object)['$ref' => 'file://' . realpath('schema.json')]);
$validator->check($data, (object)['$ref' => 'file://' . realpath('schema.json')]); //either provide PHY schema (after json_decode) or just point out to the correct schema on the local filesystem
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHP?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PHY - Physical. Might be misleading, sorry. The point was - either provide object after JSON decode, either provide a link to your schema on the filesystem.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go with something more clear


if ($validator->isValid()) {
echo "The supplied JSON validates against the schema.\n";
Expand Down