Actions

API16

JRegistryFormatJSON/stringToObject

From Joomla! Documentation

< API16:JRegistryFormatJSON
Replacement filing cabinet.png
This Namespace has been archived - Please Do Not Edit or Create Pages in this namespace. Pages contain information for a Joomla! version which is no longer supported. It exists only as a historical reference, will not be improved and its content may be incomplete.

Contents

Description

Parse a JSON formatted string and convert it into an object.

[Edit Descripton]

Description:JRegistryFormatJSON/stringToObject

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;
}

[Edit See Also] SeeAlso:JRegistryFormatJSON/stringToObject

Examples

<CodeExamplesForm />