-
-
Save ashecret/1250381d27fdc94466db971cf7bb903a to your computer and use it in GitHub Desktop.
use json_encode & json_decode at old php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//JSON.php -> http://pear.php.net/package/Services_JSON/ | |
require_once 'JSON.php'; | |
if ( !function_exists('json_decode') ){ | |
function json_decode($content, $assoc=false){ | |
if ( $assoc ){ | |
$json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); | |
} else { | |
$json = new Services_JSON; | |
} | |
return $json->decode($content); | |
} | |
} | |
if ( !function_exists('json_encode') ){ | |
function json_encode($content){ | |
$json = new Services_JSON; | |
return $json->encodeUnsafe($content); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment