Skip to content

GetDKAN/RootedJsonData

Repository files navigation

RootedJsonData

Build status Maintainability Test Coverage

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

About

Access and modify JSON-based data objects while enforcing JSON Schema

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages