HomePhabricator

Add encodeAsList to PhutilJSON and make formatting prettier

Description

Add encodeAsList to PhutilJSON and make formatting prettier

Summary:
Ref T8973. Ref T7419. Two issues:

  • In documenting T7419, I want to pretty print a JSON list value (an example value for lint and unit when calling harbormaster.sendmessage). Expose a public method for this.
  • T8973 discusses PHP's default behavior of escaping forward slashes in JSON. This is legal, but cumbersome. When pretty-printing for human users, disable it if we have a recent-enough PHP version.

Test Plan:

  • See next diffs.
  • Pretty-printed lists with values that contain slashes, got friendly/helpful results:

Screen Shot 2015-08-04 at 12.27.12 PM.png (337×622 px, 38 KB)

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T7419, T8973

Differential Revision: https://secure.phabricator.com/D13787