Bug #74859 [Opn->Fbk]: json_decode unexpected behaviour

From: Date: Wed, 05 Jul 2017 18:33:41 +0000
Subject: Bug #74859 [Opn->Fbk]: json_decode unexpected behaviour
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-209830@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74859&edit=1 ID: 74859 Updated by: peehaa@php.net Reported by: emimarz at gmail dot com Summary: json_decode unexpected behaviour -Status: Open +Status: Feedback Type: Bug Package: JSON related Operating System: linux PHP Version: Irrelevant Block user comment: N Private report: N New Comment: What unexpected behavior? Please explain what is expected and why and what the actual result is. Previous Comments: ------------------------------------------------------------------------ [2017-07-05 18:24:36] emimarz at gmail dot com Description: ------------ this unexpected behaviour happen on php 5.* and 7.1 with json_decode Test script: --------------- <?php $son = '{ "1":{ "id":"1", "name":"jack" }, "2":{ "id":"2", "name":"john" } }'; $json = (array) json_decode($son); //var_dump($json); var_dump($json['1']); // incorrect result var_dump($json[1]); // incorrect result $json = json_decode($son,true); var_dump($json['1']); // correct result ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=74859&edit=1

« previous php.bugs (#209830) next »