Go to most recent revision |
Blame |
Compare with Previous |
Last modification |
View Log
| RSS feed
<?php
declare(strict_types=1);
namespace aywan\JsonCanonicalization;
class Canonicalizator implements JsonCanonicalizationInterface
{
const JSON_FLAGS = \JSON_UNESCAPED_UNICODE | \JSON_UNESCAPED_SLASHES;
public function canonicalize($data, bool $asHex = false): string
{
return $asHex ? Utils::asHex($result) : $result;
}
private function serialize($item)/*: void*/ // ViaThinkSoft: Removed ": void" for PHP 7.0 compatibility
{
echo Utils::es6NumberFormat($item);
return;
}
return;
}
if (is_array($item) && ! Utils
::isAssoc($item)) {
echo '[';
$next = false;
foreach ($item as $element) {
if ($next) {
echo ',';
}
$next = true;
}
echo ']';
return;
}
}
uksort($item, function (string
$a, string
$b) {
});
echo '{';
$next = false;
foreach ($item as $key => $value) {
if ($next) {
echo ',';
}
$next = true;
}
echo '}';
}
}