https://bugzilla.wikimedia.org/show_bug.cgi?id=71284

--- Comment #5 from Antoine "hashar" Musso <[email protected]> ---
The script is in integration/jenkins.git bin/json-lint.php  It uses PHP
json_decode() to parse the json.

And with PHP 5.4.24:

 php > var_dump( json_decode( '{ "key": 1, "key": 2}' ) );
 class stdClass#1 (1) {
   public $key =>
   int(2)
 }
 php > 

The first key is overridden.

One can look at the JSON RFC http://tools.ietf.org/html/rfc7159#section-4 which
states:

>   [..] When the names within an object are not
>   unique, the behavior of software that receives such an object is
>   unpredictable.  Many implementations report the last name/value pair
>   only.  Other implementations report an error or fail to parse the
>   object, and some implementations report all of the name/value pairs,
>   including duplicates.


Ideally we would propose to upstream PHP an option to json_decode() which would
warn/fatal/except whenever a dupe is encountered.

Meanwhile one will have to figure out how to parse json "manually" and detect
such error. Which is hmm cumbersome.

Patch welcome.

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to