note 95457 deleted from function.json-encode by thiago
| From: | thiago@php.net | Date: | Mon, 04 Jan 2010 13:00:16 +0000 |
| Subject: | note 95457 deleted from function.json-encode by thiago | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-164592@lists.php.net to get a copy of this message | ||
Note Submitter: rene
----
hmm. even with error_reporting(0), json_encode() throws warnings when it encounters a resource type
variable;
(php_json_encode) type is unsupported, encoded as null
so from now on i do:
$json = json_encode(json_prepare($complexVariable));
function json_prepare ($v) {
if (is_array($v)) {
foreach ($v as $k=>$w) {
$v[$k] = json_prepare($w);
}
} elseif (is_resource($v)) {
$v = '[php resource; '.get_resource_type($v).']';
}
return $v;
}