class JsonBrowser

Helper class for working with JSON-encoded data

Constants

OPT_NONEXISTENT_EXCEPTIONS

Throw exceptions instead of using NULL for nonexistent children & siblings

ERR_DECODING_ERROR

Error decoding JSON data

ERR_UNKNOWN_TYPE

Encountered an unknown type

ERR_UNKNOWN_CHILD

Unknown child

ERR_UNKNOWN_SIBLING

Unknown sibling

TYPE_NULL

NULL type

TYPE_BOOLEAN

Boolean type

TYPE_STRING

String type

TYPE_NUMBER

Number type

TYPE_INTEGER

Integer type (subset of TYPE_NUMBER)

TYPE_ARRAY

Array type

TYPE_OBJECT

Object type

Methods

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

Create a new instance

string
getPath()

Get the node path

mixed
getValue()

Get the document value

int
getType()

Get the document value type

getRoot()

Get root node

getParent()

Get parent node

bool
childExists(mixed $key)

Check whether a child element exists

getChild(mixed $key)

Get a child node

bool
siblingExists(mixed $key)

Check whether a sibling exists

getSibling(mixed $key)

Get a sibling node

getNodeAt(string $path)

Get the node at a given path

Details

at line 74
__construct(string $json, int $options = 0)

Create a new instance

Parameters

string $json JSON-encoded data
int $options Configuration options (bitmask)

at line 107
string getPath()

Get the node path

Return Value

string The node path as a JSON pointer

at line 117
mixed getValue()

Get the document value

Return Value

mixed

at line 127
int getType()

Get the document value type

Return Value

int

at line 165
JsonBrowser getRoot()

Get root node

Return Value

JsonBrowser Root node

at line 175
JsonBrowser|null getParent()

Get parent node

Return Value

JsonBrowser|null Parent node

at line 186
bool childExists(mixed $key)

Check whether a child element exists

Parameters

mixed $key Index key

Return Value

bool Whether the given child exists

at line 204
JsonBrowser getChild(mixed $key)

Get a child node

Parameters

mixed $key Index key

Return Value

JsonBrowser Child node

at line 233
bool siblingExists(mixed $key)

Check whether a sibling exists

Parameters

mixed $key Index key

Return Value

bool Whether the sibling exists

at line 249
JsonBrowser getSibling(mixed $key)

Get a sibling node

Parameters

mixed $key Index key

Return Value

JsonBrowser

at line 266
JsonBrowser getNodeAt(string $path)

Get the node at a given path

Parameters

string $path JSON pointer to the requested node

Return Value

JsonBrowser