Req #69936 [Opn->Fbk]: enhancement to json_decode -- an option to keep duplicate keys in an array

From: Date: Fri, 26 Jun 2015 01:49:53 +0000
Subject: Req #69936 [Opn->Fbk]: enhancement to json_decode -- an option to keep duplicate keys in an array
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-193899@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69936&edit=1

 ID:                 69936
 Updated by:         requinix@php.net
 Reported by:        floriparob at gmail dot com
 Summary:            enhancement to json_decode -- an option to keep
                     duplicate keys in an array
-Status:             Open
+Status:             Feedback
 Type:               Feature/Change Request
 Package:            JSON related
 Operating System:   Debian stretch/sid
 PHP Version:        5.6.10
 Block user comment: N
 Private report:     N

 New Comment:

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?


Previous Comments:
------------------------------------------------------------------------
[2015-06-26 01:47:39] 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:42:00] 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.



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=69936&edit=1


Thread (4 messages)

« previous php.bugs (#193899) next »