Bug #70445 [NEW]: json_encode bug

From: Date: Mon, 07 Sep 2015 10:24:55 +0000
Subject: Bug #70445 [NEW]: json_encode bug
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-195830@lists.php.net to get a copy of this message
From: fedor at support-pc dot org Operating system: ubuntu and debian PHP version: 5.6.13 Package: JSON related Bug Type: Bug Bug description:json_encode bug Description: ------------ error to converting array to json I have a big array, generated by php. Data for array i recive from another server by rest API. Then i use json_encode function and write result to file. But some of array value cant correct convert by slashing. example of generated array: https://openitstudio.ru/php-error-report/input.array example of generated json: https://openitstudio.ru/php-error-report/output.json For example on line 33168 in input.array: [FatherName] => Yur'evna string "Yur'evna" convert not correct. Has no escaping char "'" Test script: --------------- function object_to_array($obj) { if(is_object($obj)) $obj = (array) $obj; if(is_array($obj)) { $new = array(); foreach($obj as $key => $val) { $new[$key] = object_to_array($val); } } else $new = $obj; return $new; } //recive from API a big oject $rueser = CRunetGateUser::Get($f_UF_RUNET); //generate array (result in file https://openitstudio.ru/php-error-report/input.array) $dump['u'.$f_UF_RUNET][] = object_to_array($rueser); $arr = json_encode($dump); //in anoter script: $runetidUesers = json_decode($arr); //have error on line 33168 in input.array -- Edit bug report at https://bugs.php.net/bug.php?id=70445&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70445&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70445&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70445&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=70445&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=70445&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=70445&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=70445&r=needscript Try newer version: https://bugs.php.net/fix.php?id=70445&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=70445&r=support Expected behavior: https://bugs.php.net/fix.php?id=70445&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=70445&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=70445&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=70445&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70445&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=70445&r=dst IIS Stability: https://bugs.php.net/fix.php?id=70445&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=70445&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=70445&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=70445&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=70445&r=mysqlcfg

« previous php.bugs (#195830) next »