note 76650 deleted from function.json-decode by nlopess
| From: | nlopess@php.net | Date: | Tue, 24 Jul 2007 22:12:24 +0000 |
| Subject: | note 76650 deleted from function.json-decode by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-128895@lists.php.net to get a copy of this message | ||
Note Submitter: Tim
----
I've found some bugs in the implementation:
json_decode() does not remove the backslashes from escape-encoded characters. The original string is
not returned in this example:
<?php
$s = "\"";
if ($s == json_decode(json_encode($s))) {
print("ok");
} else {
print("The original string was not returned");
}
?>
Also, json_decode() does not fail gracefully on some input. For example, the following causes PHP to
seg fault:
<?php
json_decode("\"");
?>
I don't know of any work around or alternative functions.