Ok this is what I get:
1.- In the pre-encoding call to _recursiveJsonExprFinder function, when a non-assoc array is passed, the "key" is setted to "null". This happen because the function Zend_Json_Encoder::encodeUnicodeString returns null when an integer is passed as param.
2.- Because of that, the after encoding replacing fails.
It could be fixed with the next patch mentioned before:
if ($key == '') {
$encodedResult = str_replace(
'"' . $magicKey . '"',
$value,
$encodedResult
);
} else {
$encodedResult = str_replace(
'"' . $key . '":"' . $magicKey . '"',
'"' . $key . '":' . $value,
$encodedResult
);
}
but it nis not neccessary because with the actual code "key" is not neccesary anymore. It is enough replacing "magicKey" by its correspondant "value":
if (count($javascriptExpressions) > 0) {
$count = count($javascriptExpressions);
for($i = 0; $i < $count; $i++) {
$magicKey = $javascriptExpressions[$i]['magicKey'];
$value = $javascriptExpressions[$i]['value'];
$encodedResult = str_replace(
'"' . $magicKey . '"',
$value,
$encodedResult
);
}
}
Anyway, to avoid unneccesary function calls when the "currentKey" is an integer (non associative array) I changed also this code:
"magicKey" => Zend_Json_Encoder::encodeUnicodeString($magicKey),
for this:
"magicKey" => (is_int($currentKey)) ? $magicKey : Zend_Json_Encoder::encodeUnicodeString($magicKey),
I have re-code "Zend_Json" and added a test to JsonTest.php to testing this bug. Test is OK now.
patches Json.php file