Source for file json.php

Documentation is available at json.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Platform
  4.  * @subpackage  Input
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM'or die;
  11.  
  12. /**
  13.  * Joomla! Input JSON Class
  14.  *
  15.  * This class decodes a JSON string from the raw request data and makes it available via
  16.  * the standard JInput interface.
  17.  *
  18.  * @package     Joomla.Platform
  19.  * @subpackage  Input
  20.  * @since       12.2
  21.  */
  22. class JInputJSON extends JInput
  23. {
  24.     /**
  25.      * @var    string  The raw JSON string from the request.
  26.      * @since  12.2
  27.      */
  28.     private $_raw;
  29.  
  30.     /**
  31.      * Constructor.
  32.      *
  33.      * @param   array  $source   Source data (Optional, default is the raw HTTP input decoded from JSON)
  34.      * @param   array  $options  Array of configuration parameters (Optional)
  35.      *
  36.      * @since   12.2
  37.      */
  38.     public function __construct(array $source nullarray $options array())
  39.     {
  40.         if (isset($options['filter']))
  41.         {
  42.             $this->filter = $options['filter'];
  43.         }
  44.         else
  45.         {
  46.             $this->filter = JFilterInput::getInstance();
  47.         }
  48.  
  49.         if (is_null($source))
  50.         {
  51.             $this->_raw file_get_contents('php://input');
  52.             $this->data = json_decode($this->_rawtrue);
  53.         }
  54.         else
  55.         {
  56.             $this->data = $source;
  57.         }
  58.  
  59.         // Set the options for the class.
  60.         $this->options = $options;
  61.     }
  62.  
  63.     /**
  64.      * Gets the raw JSON string from the request.
  65.      *
  66.      * @return  string  The raw JSON string from the request.
  67.      *
  68.      * @since   12.2
  69.      */
  70.     public function getRaw()
  71.     {
  72.         return $this->_raw;
  73.     }
  74. }

Documentation generated on Tue, 19 Nov 2013 15:06:18 +0100 by phpDocumentor 1.4.3