Good day. There was a problem: the json string is sent via the post and decrypted. Similarly, the same array is created, encrypted into the json string and also decoded. Externally, the lines are the same, but in the first case the line does not expand into an array. As it was possible to establish, extra 90 bytes are written to the string. Where could they come from? Thank you in advance.
Code:
var_dump(iconv('windows-1251', 'utf-8', $_POST['data'])); echo '<br>'; var_dump(json_decode($_POST['data'], true)); echo '<br><br>'; $ar = array( 1 => array( 1 => '11', 2 => '222', 4 => '4444', 'sid' => '1', ), ); var_dump($ar = json_encode($ar)); echo '<br>'; var_dump(json_decode($ar, true)); /* Вывод: string(137) "{"1":{"1":"11","2":"222","4":"4444","sid":"1"}}" NULL string(47) "{"1":{"1":"11","2":"222","4":"4444","sid":"1"}}" array(1) { [1]=> array(4) { [1]=> string(2) "11" [2]=> string(3) "222" [4]=> string(4) "4444" ["sid"]=> string(1) "1" } } Тип ошибки: JSON_ERROR_SYNTAX - Syntax error */