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
Unknown Object (File)
Wed, Apr 17, 1:45 PM
Unknown Object (File)
Wed, Apr 17, 1:45 PM
Unknown Object (File)
Wed, Apr 17, 1:45 PM
Unknown Object (File)
Wed, Apr 17, 1:45 PM
Unknown Object (File)
Fri, Apr 12, 9:19 AM
Unknown Object (File)
Thu, Apr 11, 7:34 PM
Unknown Object (File)
Thu, Apr 11, 10:06 AM
Unknown Object (File)
Tue, Apr 9, 12:12 PM
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