Elgg
Version 4.x
|
Encode and decode JSON while converting empty string keys to a unique token. More...
Public Member Functions | |
__construct ($empty_key= '') | |
Constructor. More... | |
getEmptyKey () | |
Get the key that represents an empty string key in JSON. More... | |
decode ($json, $assoc=false, $depth=512, $options=0) | |
Decode JSON while converting empty keys to a unique token. More... | |
encode ($value, $options=0, $depth=512) | |
Encode JSON while converting unique token keys to empty strings. More... | |
Protected Attributes | |
$token | |
Encode and decode JSON while converting empty string keys to a unique token.
This gets around PHP's limitation of not allowing empty string object property names. https://bugs.php.net/bug.php?id=46600
Definition at line 13 of file EmptyKeyEncoding.php.
Elgg\Json\EmptyKeyEncoding::__construct | ( | $empty_key = '' | ) |
Constructor.
string | $empty_key | Optional key to replace "" keys with in JSON decode |
Definition at line 25 of file EmptyKeyEncoding.php.
Elgg\Json\EmptyKeyEncoding::decode | ( | $json, | |
$assoc = false , |
|||
$depth = 512 , |
|||
$options = 0 |
|||
) |
Decode JSON while converting empty keys to a unique token.
string | $json | JSON string |
bool | $assoc | Convert objects to assoc arrays? |
int | $depth | Allowed recursion depth |
int | $options | Bitmask json_decode options |
Definition at line 52 of file EmptyKeyEncoding.php.
Elgg\Json\EmptyKeyEncoding::encode | ( | $value, | |
$options = 0 , |
|||
$depth = 512 |
|||
) |
Encode JSON while converting unique token keys to empty strings.
mixed | $value | Value to encode |
int | $options | Encoding options |
int | $depth | Allowed recursion depth. Do not set this before PHP 5.5 |
Definition at line 68 of file EmptyKeyEncoding.php.
Elgg\Json\EmptyKeyEncoding::getEmptyKey | ( | ) |
Get the key that represents an empty string key in JSON.
Definition at line 37 of file EmptyKeyEncoding.php.
|
protected |
Definition at line 18 of file EmptyKeyEncoding.php.