API16

JRegistryFormatJSON/stringToObject

< API16:JRegistryFormatJSON

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

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


Advertisement