| Server IP : 213.186.33.4 / Your IP : 216.73.216.193 Web Server : Apache System : Linux webm006.cluster103.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : awebpaca ( 35430) PHP Version : 8.5.0 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/awebpaca/blog/libraries/vendor/joomla/registry/src/Format/ |
Upload File : |
<?php
/**
* Part of the Joomla Framework Registry Package
*
* @copyright Copyright (C) 2005 - 2016 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
namespace Joomla\Registry\Format;
use Joomla\Registry\AbstractRegistryFormat;
/**
* JSON format handler for Registry.
*
* @since 1.0
*/
class Json extends AbstractRegistryFormat
{
/**
* Converts an object into a JSON formatted string.
*
* @param object $object Data source object.
* @param array $options Options used by the formatter.
*
* @return string JSON formatted string.
*
* @since 1.0
*/
public function objectToString($object, $options = array())
{
$bitmask = isset($options['bitmask']) ? $options['bitmask'] : 0;
// The depth parameter is only present as of PHP 5.5
if (version_compare(PHP_VERSION, '5.5', '>='))
{
$depth = isset($options['depth']) ? $options['depth'] : 512;
return json_encode($object, $bitmask, $depth);
}
return json_encode($object, $bitmask);
}
/**
* Parse a JSON formatted string and convert it into an object.
*
* If the string is not in JSON format, this method will attempt to parse it as INI format.
*
* @param string $data JSON formatted string to convert.
* @param array $options Options used by the formatter.
*
* @return object Data object.
*
* @since 1.0
* @throws \RuntimeException
*/
public function stringToObject($data, array $options = array('processSections' => false))
{
$data = trim($data);
if ((substr($data, 0, 1) != '{') && (substr($data, -1, 1) != '}'))
{
return AbstractRegistryFormat::getInstance('Ini')->stringToObject($data, $options);
}
$decoded = json_decode($data);
// Check for an error decoding the data
if ($decoded === null)
{
throw new \RuntimeException(sprintf('Error decoding JSON data: %s', json_last_error_msg()));
}
return $decoded;
}
}