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)
Mon, Nov 18, 11:29 AM
Unknown Object (File)
Mon, Nov 18, 11:29 AM
Unknown Object (File)
Mon, Nov 18, 11:29 AM
Unknown Object (File)
Mon, Nov 18, 11:29 AM
Unknown Object (File)
Mon, Nov 18, 11:16 AM
Unknown Object (File)
Sun, Nov 17, 9:05 PM
Unknown Object (File)
Thu, Nov 14, 6:28 AM
Unknown Object (File)
Sat, Nov 9, 10:25 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