Magento’s Core JSON Encoding and Decoding Functions

To JSON encode an array
$jsonData = Mage::helper(‘core’)->jsonEncode($array);

To JSON decode an array
$array = Mage::helper(‘core’)->jsonDecode($jsonData);

3 replies on “Magento’s Core JSON Encoding and Decoding Functions”

Out of curiosity what is the advantage to using this over simply calling Zend_Json::encode/decode()?

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.

Comments are closed.