note 118144 deleted from function.json-decode by salathe
| From: | salathe@php.net | Date: | Mon, 21 Sep 2020 14:59:58 +0000 |
| Subject: | note 118144 deleted from function.json-decode by salathe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-215414@lists.php.net to get a copy of this message | ||
Note Submitter: descartavel1+php at gmail dot com
----
<?php
/* wrapper to php's json_encode to work around the fact that some options we use are
* not available on php5.2, which we still support
* call to json_encode is silenced as we don't care about encoding warnings
*/
public static function php_json_encode_as_object($input){
if( (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 3)
|| PHP_MAJOR_VERSION < 5
){
// no support for JSON_FORCE_OBJECT
return @json_encode((object)$input);
}else{
return @json_encode($input, JSON_FORCE_OBJECT);
}
}
?>