Summary: These are technically in MetaMTA right now, but I put them in Differential since I think it's probably a better primary category fit and having 120 options in MetaMTA won't do anyone any favors. (We can do some kind of cross-categorization or "related options" later if we get feedback that people are having trouble finding options like these which have multiple reasonable categories.) Also improve the readability of displayed JSON literals with forward slashes. Test Plan: Looked at options, edited a couple of them. Looked at JSON literal values, saw them rendered more readably. Reviewers: codeblock, btrahan Reviewed By: codeblock CC: aran Maniphest Tasks: T2255 Differential Revision: https://secure.phabricator.com/D4464
26 lines
905 B
PHP
26 lines
905 B
PHP
<?php
|
|
|
|
final class PhabricatorConfigJSON {
|
|
/**
|
|
* Properly format a JSON value.
|
|
*
|
|
* @param wild Any value, but should be a raw value, not a string of JSON.
|
|
* @return string
|
|
*/
|
|
public static function prettyPrintJSON($value) {
|
|
// Check not only that it's an array, but that it's an "unnatural" array
|
|
// meaning that the keys aren't 0 -> size_of_array.
|
|
if (is_array($value) && array_keys($value) != range(0, count($value) - 1)) {
|
|
return id(new PhutilJSON())->encodeFormatted($value);
|
|
} else {
|
|
$result = json_encode($value);
|
|
// For readability, unescape forward slashes. These are normally escaped
|
|
// to prevent the string "</script>" from appearing in a JSON literal,
|
|
// but it's irrelevant here and makes reading paths more difficult than
|
|
// necessary.
|
|
$result = str_replace('\\/', '/', $result);
|
|
return $result;
|
|
}
|
|
}
|
|
}
|