Bug #73362 [Fbk->Csd]: json_decode returns dupliate keys when $assoc is set to true

From: Date: Fri, 21 Oct 2016 03:35:42 +0000
Subject: Bug #73362 [Fbk->Csd]: json_decode returns dupliate keys when $assoc is set to true
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-204945@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73362&edit=1 ID: 73362 User updated by: vvsraju0404 at gmail dot com Reported by: vvsraju0404 at gmail dot com Summary: json_decode returns dupliate keys when $assoc is set to true -Status: Feedback +Status: Closed Type: Bug Package: JSON related Operating System: GNU/Linux CentOS release 6.7 PHP Version: 5.6.27 Block user comment: N Private report: N New Comment: There was a space in the key which is considered as different key . Thank you. Previous Comments: ------------------------------------------------------------------------ [2016-10-21 03:27:15] requinix@php.net Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. Seems to be working fine. https://3v4l.org/TrZEE ------------------------------------------------------------------------ [2016-10-21 03:23:19] vvsraju0404 at gmail dot com Description: ------------ I am fetching a JSON from webservice which is returning data with duplicate keys . curl_setopt($ch, CURLOPT_URL, $url); $result = curl_exec($ch); $json_result = json_decode($result,true); When i decode the JSON with json_decode with $assoc flag as true ; i was expecting that as the result is associative array , there wouldn't be any duplicates but $json_result has duplicate keys . Expected result: ---------------- When i decode the JSON with json_decode with $assoc flag as true, there shouldn't be any duplicate keys as returned data structure is associative array . ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=73362&edit=1

« previous php.bugs (#204945) next »