To JSON encode an array
[php]
$jsonData = Mage::helper(‘core’)->jsonEncode($array);
[/php]
To JSON decode an array
[php]
$array = Mage::helper(‘core’)->jsonDecode($jsonData);
[/php]
To JSON encode an array
[php]
$jsonData = Mage::helper(‘core’)->jsonEncode($array);
[/php]
To JSON decode an array
[php]
$array = Mage::helper(‘core’)->jsonDecode($jsonData);
[/php]
Comments are closed.
Out of curiosity what is the advantage to using this over simply calling Zend_Json::encode/decode()?
You can do that! That should work. The idea is to stay within Magento’s scope as much as possible.
There is a difference, when using the core magento helper the json data gets passed through the inline translator (if enabled) so your strings will get translated, if you use Zend_Json directly it won’t.