php.net |  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
Votes:1
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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: vvsraju0404 at gmail dot com
New email:
PHP Version: OS:

 

 [2016-10-21 03:23 UTC] 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 .


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-10-21 03:27 UTC] requinix@php.net
-Status: Open +Status: Feedback
 [2016-10-21 03:27 UTC] 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: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] requinix@php.net
-Status: Closed +Status: Not a bug
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 10:01:28 2024 UTC