Download the PHP package johnstevenson/json-works without Composer
On this page you can find all versions of the php package johnstevenson/json-works. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download johnstevenson/json-works
More information about johnstevenson/json-works
Files in johnstevenson/json-works
Package json-works
Short Description Create, edit, query and validate json
License MIT
Homepage http://github.com/johnstevenson/json-works
Informations about the package json-works
Json-Works
A PHP library to create, edit, query and validate JSON.
Installation
Install the latest version with:
Requirements
- PHP 7.4 minimum, although using the latest PHP version is highly recommended.
Usage
The library is intended to be used with complex json structures, or with json data that needs validation. Full usage information is available in the documentation.
- Overview
- Validation
Overview
Json-Works allows you to create, edit and query json data using JSON Pointer syntax. For example:
which will give you the following json:
You can query this value by calling:
and update it with:
and move it with:
to end up with:
then delete it with:
Validation
Json-Works includes an implementation of JSON Schema, version 4, which allows you to
validate json data. If the document contains invalid or missing value data, the validation will fail
with the error in $document->getError()
.
You can also validate data whilst building a document. The following example schema describes an array containing objects whose properties are all required and whose types are defined.
Now you can check if your data is valid:
Without a schema, any value can be added anywhere.
License
Json-Works is licensed under the MIT License - see the LICENSE
file for details.