encodeAsList($value); break; case 'object': $result = id(new PhutilJSON())->encodeFormatted($value); break; default: $result = json_encode($value); break; } // For readability, unescape forward slashes. These are normally escaped // to prevent the string "" 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; } }