json_encoding.inc.php 773 B

1234567891011121314151617181920212223242526
  1. <?php
  2. // Ensures the json_encode and json_decode functions are available.
  3. // Only necessary for PHP4. In PHP5 they're already there.
  4. // Uses the JSON.php file from PEAR.
  5. if (!function_exists('json_decode')) {
  6. function json_decode($content, $assoc=false) {
  7. require_once(realpath(dirname(__FILE__) . "/" . "JSON.php"));
  8. if ($assoc) {
  9. $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
  10. }
  11. else {
  12. $json = new Services_JSON;
  13. }
  14. return $json->decode($content);
  15. }
  16. }
  17. if (!function_exists('json_encode')) {
  18. function json_encode($content) {
  19. require_once(realpath(dirname(__FILE__) . "/" . "JSON.php"));
  20. $json = new Services_JSON;
  21. return $json->encode($content);
  22. }
  23. }
  24. ?>