|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #69936 enhancement to json_decode -- an option to keep duplicate keys in an array
Submitted: 2015-06-26 01:42 UTC Modified: 2015-07-05 04:22 UTC
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:2 (100.0%)
From: floriparob at gmail dot com Assigned:
Status: No Feedback Package: JSON related
PHP Version: 5.6.10 OS: Debian stretch/sid
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: floriparob at gmail dot com
New email:
PHP Version: OS:


 [2015-06-26 01:42 UTC] floriparob at gmail dot com
Using json_decode to turn a JSON string into an associative array. If it finds duplicate key:value pairs it drops the duplicate.
It would be handy to have an option to keep or not to keep these duplicates.


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-26 01:47 UTC]
That's not possible: arrays can't have duplicate keys.

What if it decoded into an array of values? Like {a:1,a:2} decoded to [a=>[1,2]]?
 [2015-06-26 01:49 UTC]
-Status: Open +Status: Feedback
 [2015-06-26 01:49 UTC]
What am I saying? {a:1,a:2} doesn't make sense as JSON either.

Do you have any examples of where this would be useful *and* are not due to flawed JSON encoders?
 [2015-07-05 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Sep 29 02:03:37 2021 UTC