xPDO.toJSON

xPDO::toJSON

Converts a PHP array into a JSON encoded string.

Syntax

API Docs: http://api.modxcms.com/xpdo/xPDO.html#toJSON

string toJSON (array $array)

Example

$ar = array('name' => 'John');
$str = $xpdo->toJSON($ar);
echo $str; // prints: {name:"John"}

See Also

Suggest an edit to this page on GitHub (Requires GitHub account. Opens a new window/tab) or become an editor of the MODX Documentation.