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
F14077134: D9627.diff
Thu, Nov 21, 9:39 PM
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
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
Branch
json4
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 1252
Build 1252: [Placeholder Plan] Wait for 30 Seconds

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