note 95935 deleted from function.json-decode by salathe
| From: | salathe@php.net | Date: | Mon, 21 Sep 2020 15:01:54 +0000 |
| Subject: | note 95935 deleted from function.json-decode by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-215441@lists.php.net to get a copy of this message | ||
Note Submitter: nix
----
Be aware, when decoding JSON strings, where an empty string is a key, this library replaces the
empty string with "_empty_".
So the following code gives an unexpected result:
<?php
var_dump(json_decode('{"":"arbitrary"}'));
?>
The result is as follows:
object(stdClass)#1 (1) {
["_empty_"]=>
string(6) "arbitrary"
}
Any subsequent key named "_empty_" (or "" [the empty string] again) will
overwrite the value.