php.net |  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
Votes:2
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
Have you experienced this issue?
Rate the importance of this bug to you:

 [2015-06-26 01:42 UTC] floriparob at gmail dot com
Description:
------------
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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-06-26 01:47 UTC] requinix@php.net
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] requinix@php.net
-Status: Open +Status: Feedback
 [2015-06-26 01:49 UTC] requinix@php.net
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-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 18:01:30 2024 UTC