xPDO.fromJSON
Last updated Apr 20th, 2021 | Page history | Improve this page | Report an issue
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' )