|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #73362 json_decode returns dupliate keys when $assoc is set to true
Submitted: 2016-10-21 03:23 UTC Modified: 2016-10-21 06:08 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: vvsraju0404 at gmail dot com Assigned:
Status: Not a bug Package: JSON related
PHP Version: 5.6.27 OS: GNU/Linux CentOS release 6.7
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: vvsraju0404 at gmail dot com
New email:
PHP Version: OS:


 [2016-10-21 03:23 UTC] vvsraju0404 at gmail dot com
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 .


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2016-10-21 03:27 UTC]
-Status: Open +Status: Feedback
 [2016-10-21 03:27 UTC]
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.
 [2016-10-21 03:35 UTC] vvsraju0404 at gmail dot com
-Status: Feedback +Status: Closed
 [2016-10-21 03:35 UTC] vvsraju0404 at gmail dot com
There was a space in the key which is considered as different key .

Thank you.
 [2016-10-21 06:08 UTC]
-Status: Closed +Status: Not a bug
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Mar 03 09:01:28 2024 UTC