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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
49 + 35 = ?
Subscribe to this entry?

 
 [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-2019 The PHP Group
All rights reserved.
Last updated: Thu Sep 19 13:01:34 2019 UTC