فهرست منبع

"resolved issue ZF-6786 in Zend_Json"

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@15874 44c647ce-9c0f-0410-b52a-842ac1e357ba
oreales 16 سال پیش
والد
کامیت
de148c2922
1فایلهای تغییر یافته به همراه8 افزوده شده و 6 حذف شده
  1. 8 6
      library/Zend/Json.php

+ 8 - 6
library/Zend/Json.php

@@ -128,12 +128,13 @@ class Zend_Json
         if (count($javascriptExpressions) > 0) {
             $count = count($javascriptExpressions);
             for($i = 0; $i < $count; $i++) {
-                $key      = $javascriptExpressions[$i]['key'];
                 $magicKey = $javascriptExpressions[$i]['magicKey'];
                 $value    = $javascriptExpressions[$i]['value'];
+
                 $encodedResult = str_replace(
-                    '"' . $key . '":"' . $magicKey . '"',
-                    '"' . $key . '":' . $value,
+                    //instead of replacing "key:magicKey", we replace directly magicKey by value because "key" never changes.
+                    '"' . $magicKey . '"',
+                    $value,
                     $encodedResult
                 );
             }
@@ -159,12 +160,13 @@ class Zend_Json
     protected static function _recursiveJsonExprFinder(
         &$value, array &$javascriptExpressions, $currentKey = null
     ) {
-        if ($value instanceof Zend_Json_Expr) {
+         if ($value instanceof Zend_Json_Expr) {
             // TODO: Optimize with ascii keys, if performance is bad
             $magicKey = "____" . $currentKey . "_" . (count($javascriptExpressions));
             $javascriptExpressions[] = array(
-                "key"      => Zend_Json_Encoder::encodeUnicodeString($currentKey),
-                "magicKey" => Zend_Json_Encoder::encodeUnicodeString($magicKey),
+
+                //if currentKey is integer, encodeUnicodeString call is not required.
+                "magicKey" => (is_int($currentKey)) ? $magicKey : Zend_Json_Encoder::encodeUnicodeString($magicKey),
                 "value"    => $value->__toString(),
             );
             $value = $magicKey;