AJAX
[ class tree: AJAX ] [ index: AJAX ] [ all elements ]

Source for file JSON.php

Documentation is available at JSON.php

  1. <?php
  2. require_once 'HTML/AJAX/JSON.php';
  3. // $Id$
  4. /**
  5.  * JSON Serializer
  6.  *
  7.  * @category   HTML
  8.  * @package    AJAX
  9.  * @author     Joshua Eichorn <josh@bluga.net>
  10.  * @copyright  2005 Joshua Eichorn
  11.  * @license    http://www.opensource.org/licenses/lgpl-license.php  LGPL
  12.  * @version    Release: @package_version@
  13.  * @link       http://pear.php.net/package/PackageName
  14.  */
  15. {
  16.  
  17.     /**
  18.      * JSON instance
  19.      * @var HTML_AJAX_JSON 
  20.      * @access private
  21.      */
  22.     var $_json;
  23.  
  24.     /**
  25.      * use json php extension http://www.aurore.net/projects/php-json/
  26.      * @access private
  27.      */
  28.     var $_jsonext;
  29.  
  30.     function HTML_AJAX_Serializer_JSON(
  31.     {
  32.         $this->_jsonext $this->_detect();
  33.         if(!$this->_jsonext)
  34.         {
  35.             $this->_json =new HTML_AJAX_JSON();
  36.         }
  37.     }
  38.  
  39.     function serialize($input
  40.     {
  41.         if($this->_jsonext)
  42.         {
  43.             return json_encode($input);
  44.         }
  45.         else
  46.         {
  47.             return $this->_json->encode($input);
  48.         }
  49.     }
  50.  
  51.     function unserialize($input
  52.     {
  53.         if($this->_jsonext)
  54.         {
  55.             return json_decode($input);
  56.         }
  57.         else
  58.         {
  59.             return $this->_json->decode($input);
  60.         }
  61.     }
  62.  
  63.     function _detect()
  64.     {
  65.         return extension_loaded('json');
  66.     }
  67. }
  68. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  69. ?>

Documentation generated on Mon, 11 Mar 2019 14:14:02 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.