Bug #70445 [Opn->Fbk]: json_encode bug
| From: | requinix@php.net | Date: | Mon, 07 Sep 2015 10:37:03 +0000 |
| Subject: | Bug #70445 [Opn->Fbk]: json_encode bug | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-195831@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70445&edit=1
ID: 70445
Updated by: requinix@php.net
Reported by: fedor at support-pc dot org
Summary: json_encode bug
-Status: Open
+Status: Feedback
Type: Bug
Package: JSON related
Operating System: ubuntu and debian
PHP Version: 5.6.13
Block user comment: N
Private report: N
New Comment:
Do you expect to see Yur\'evna? JSON does not need to escape 's.
Do you get an error with json_decode()? What is the error message?
json_decode(file_get_contents("https://openitstudio.ru/php-error-report/output.json"))
works correctly for me.
Previous Comments:
------------------------------------------------------------------------
[2015-09-07 10:24:53] fedor at support-pc dot org
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 this bug report at https://bugs.php.net/bug.php?id=70445&edit=1