Page MenuHomePhabricator

Add an optional mode for `PhutilJSONParser` to detect duplicate keys
ClosedPublic

Authored by joshuaspence on Jun 19 2014, 1:58 AM.
Tags
None
Referenced Files
F15460558: D9627.id23117.diff
Mon, Mar 31, 11:58 PM
F15449954: D9627.diff
Fri, Mar 28, 1:08 PM
F15428795: D9627.id.diff
Sun, Mar 23, 10:21 PM
F15420926: D9627.id23113.diff
Fri, Mar 21, 7:06 PM
F15408814: D9627.id23117.diff
Wed, Mar 19, 1:31 AM
F15408813: D9627.id23091.diff
Wed, Mar 19, 1:31 AM
F15408812: D9627.id23113.diff
Wed, Mar 19, 1:31 AM
F15404093: D9627.id.diff
Tue, Mar 18, 6:10 AM
Subscribers

Details

Summary

Ref T5297. Change PhutilJSONParser to disallow duplicate keys by default. In addition, add an optional mode to allow duplicate keys. One important caveat here is that PhutilJSONParser will return the first value in the case of a duplicate, whereas json_decode will return the last value.

Depends on D9624.

Test Plan

Wrote and executed unit tests.

Diff Detail

Repository
rPHU libphutil
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

joshuaspence retitled this revision from to Add an optional mode for `PhutilJSONParser` to detect duplicate keys.
joshuaspence updated this object.
joshuaspence edited the test plan for this revision. (Show Details)
joshuaspence added a reviewer: epriestley.
epriestley edited edge metadata.
This revision is now accepted and ready to land.Jun 19 2014, 6:01 PM
joshuaspence edited edge metadata.

I've changed this a bit since it was initially accepted.

epriestley edited edge metadata.
epriestley added inline comments.
src/parser/PhutilJSONParser.php
14–15

For consistency, return $this;.

This revision is now accepted and ready to land.Jun 20 2014, 1:38 AM