getdkan / rooted-json-data
Access and modify JSON-based data objects while enforcing JSON Schema
Installs: 95 767
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 4
Forks: 0
Open Issues: 4
Requires
- ext-json: *
- galbar/jsonpath: ^3.0
- opis/json-schema: ^1.0.8
Requires (Dev)
- phpunit/phpunit: ^9.4
- rector/rector: ^0.15.19
- squizlabs/php_codesniffer: ^3.7
- symfony/phpunit-bridge: ^7.0
This package is auto-updated.
Last update: 2024-11-23 13:09:25 UTC
README
Access and modify JSON-based data objects while enforcing JSON Schema.
This library primarily wires together JsonPath-PHP and Opis JSON Schema, providing a JSON Object class that functions like a small internal service. Data can be added, retrieved and modified through a simple API, and any changes will immediately provoke a re-validation. Validation errors through exceptions with actionable messages.
Example:
$json = '{"number":3}'; $schema = '{"type": "object","properties": {"number":{ "type": "number" }}}'; $data = new RootedJsonData($json, $schema); echo $data->{"$.number"}; // 3 echo $data->{"$[number]"}; // 3 echo "{$data}"; // {"number":3} $data->{"$.number"} = "three"; // EXCEPTION