Thomas Gelf 8c04de0a14 ImportsourceHookTable: show malformed data...
...plus some namespacing/cleanup
2019-04-04 13:22:39 +02:00

31 lines
672 B
PHP

<?php
namespace Icinga\Module\Director\Core;
use Icinga\Module\Director\Exception\JsonEncodeException;
class Json
{
public static function encode($mixed, $flags = null)
{
$result = \json_encode($mixed, $flags);
if ($result === false && json_last_error() !== JSON_ERROR_NONE) {
throw JsonEncodeException::forLastJsonError();
}
return $result;
}
public static function decode($string)
{
$result = \json_decode($string);
if ($result === null && json_last_error() !== JSON_ERROR_NONE) {
throw JsonEncodeException::forLastJsonError();
}
return $result;
}
}