Esempio n. 1
0
 static function PackJsonObject(&$binstr_writebuf, &$seek, $_object, &$pubdict, &$localdict, $riseDictByKey, $riseDictByString)
 {
     $ocount = count((array) $_object);
     JsonPack::WriteObjectCountHead($binstr_writebuf, $seek, $ocount);
     foreach ($_object as $key => $value) {
         if (strlen($key) < 2) {
             JsonPack::WriteStringDataDirect($binstr_writebuf, $seek, $key);
         } else {
             $pid = JsonPack::GetKey($pubdict, $key);
             if ($pid >= 0) {
                 JsonPack::WriteStringDataDict($binstr_writebuf, $seek, true, $pid);
             } else {
                 if ($riseDictByKey) {
                     $pid = JsonPack::GetFreeKey($pubdict);
                     $pubdict[] = key;
                     JsonPack::WriteStringDataDict($binstr_writebuf, $seek, true, $pid);
                 } else {
                     if (in_array($key, $localdict) == false) {
                         $localdict[] = $key;
                     }
                     $pid = JsonPack::GetKey($localdict, $key);
                     JsonPack::WriteStringDataDict($binstr_writebuf, $seek, false, $pid);
                 }
             }
         }
     }
     foreach ($_object as $key => $value) {
         JsonPack::PackJson($binstr_writebuf, $seek, $value, $pubdict, $localdict, $riseDictByKey, $riseDictByString);
     }
 }