Yes
$string = 'Hello There'; var_dump( Mage::helper('core')->jsonEncode($string) ); var_dump( json_encode($string) );
I was never clear if this encoding of string data types other than objects like a javascript string is a side effect of JSON encoding or if it is true according to Hoyle Crockford JSON, so I always love to wrap my strings in an object when I pass them around
$o = new stdClass(); $o->param = 'This is my Param'; $json = json_encode($o); echo 'var data = ' . $json . ';' . "\n"; echo 'var jsdata = data.param';
Here's how you handle this with javascript. There is no method that was specifically created for this. If you are interested in finding out what auxiliary methods you have in a block, check out the methods in
app/code/core/Mage/Core/Block/Abstract.php app/code/core/Mage/Core/Block/Template.php
and if you are dealing with a template that part of the block is above the chain, get its class, and then check its definition
var_dump get_class($this);
Alan storm
source share