class Context

Document context

Methods

__construct(JsonBrowser $root, string $json, int $options = 0)

Create a new instance

bool
valueExists(array $path)

Check whether the value at a given path exists

mixed|null
getValue(array $path, bool $exists = null)

Get the value at a given path

setValue(array $path, mixed $value, bool $padSparseArray = false)

Set the value at a given path

deleteValue(array $path, bool $deleteEmpty = false)

Delete the value at a given path

Details

at line 37
__construct(JsonBrowser $root, string $json, int $options = 0)

Create a new instance

Parameters

JsonBrowser $root JsonBrowser for root node
string $json JSON-encoded data
int $options Configuration options (bitmask)

at line 73
bool valueExists(array $path)

Check whether the value at a given path exists

Parameters

array $path Array of path elements

Return Value

bool Whether a value exists at the given path

at line 88
mixed|null getValue(array $path, bool $exists = null)

Get the value at a given path

Parameters

array $path Array of path elements
bool $exists Reference - set to true if the value exists, false otherwise

Return Value

mixed|null Value data, or null if value does not exist

at line 118
setValue(array $path, mixed $value, bool $padSparseArray = false)

Set the value at a given path

Parameters

array $path Array of path elements
mixed $value Value data to set
bool $padSparseArray Whether to left-pad sparse arrays with null values

at line 167
deleteValue(array $path, bool $deleteEmpty = false)

Delete the value at a given path

Parameters

array $path Array of path elements
bool $deleteEmpty Whether to delete empty containers