Jump to main content Jump to doc navigation

xPDO::fromJSON

Converts a JSON source string into an equivalent PHP representation.

Syntax

API Docs: https://api.modx.com/revolution/2.2/db_core_xpdo_xpdo.class.html#\xPDO::fromJSON()

mixed fromJSON (string $src, [boolean $asArray = true])

Example

Convert JSON code to an array:

$str = '{name:"John"}';
$ar = $xpdo->fromJSON($str);
print_r($ar); // prints: Array ( 'name' => 'John' )

See Also