API16:JRegistryFormatJSON/stringToObject
From Joomla! Documentation
Description
Parse a JSON formatted string and convert it into an object.
Syntax
stringToObject($data, $process_sections=false)
Parameter Name | Default Value | Description |
---|---|---|
$data | JSON formatted string to convert. | |
$process_sections | false | Options used by the formatter. |
Returns
object Data object.
Defined in
libraries/joomla/registry/format/json.php
Importing
jimport( 'joomla.registry.format.json' );
Source Body
public function stringToObject($data, $process_sections = false)
{
$data = trim($data);
if ((substr($data, 0, 1) != '{') && (substr($data, -1, 1) != '}')) {
$ini = & JRegistryFormat::getInstance('INI');
$obj = $ini->stringToObject($data, $process_sections);
} else {
$obj = json_decode($data);
}
return $obj;
}
Examples
Code Examples