Prefer Json::encode() over json_encode()

refs #2635
This commit is contained in:
Alexander A. Klimov 2018-04-27 17:25:22 +02:00
parent 9219cea776
commit 1a94a21263
5 changed files with 9 additions and 5 deletions

View File

@ -9,6 +9,7 @@ use Icinga\Application\Logger\Writer\FileWriter;
use Icinga\Application\Logger\Writer\SyslogWriter;
use Icinga\Exception\ConfigurationError;
use Icinga\Exception\IcingaException;
use Icinga\Util\Json;
/**
* Logger
@ -251,7 +252,7 @@ class Logger
function ($a) {
return is_string($a) ? $a : ($a instanceof Exception
? IcingaException::describe($a)
: json_encode($a));
: Json::encode($a));
},
$arguments
)

View File

@ -3,6 +3,7 @@
namespace Icinga\Web\Announcement;
use Icinga\Util\Json;
use Icinga\Web\Cookie;
/**
@ -128,7 +129,7 @@ class AnnouncementCookie extends Cookie
*/
public function getValue()
{
return json_encode(array(
return Json::encode(array(
'acknowledged' => $this->getAcknowledged(),
'etag' => $this->getEtag(),
'next' => $this->getNextActive()

View File

@ -3,6 +3,7 @@
namespace Icinga\Web\Response;
use Icinga\Util\Json;
use Zend_Controller_Action_HelperBroker;
use Icinga\Web\Response;
@ -190,7 +191,7 @@ class JsonResponse extends Response
$body['data'] = $this->getSuccessData();
break;
}
echo json_encode($body, $this->getEncodingOptions());
echo Json::encode($body, $this->getEncodingOptions());
}
/**

View File

@ -10,6 +10,7 @@ use Icinga\Cli\Command;
use Icinga\File\Csv;
use Icinga\Module\Monitoring\Plugin\PerfdataSet;
use Exception;
use Icinga\Util\Json;
/**
* Icinga monitoring objects
@ -78,7 +79,7 @@ class ListCommand extends Command
$query = $query->getQuery();
switch ($format) {
case 'json':
echo json_encode($query->fetchAll());
echo Json::encode($query->fetchAll());
break;
case 'csv':
Csv::fromQuery($query)->dump();

View File

@ -173,7 +173,7 @@ class RestRequest
{
switch ($contentType) {
case 'application/json':
$payload = json_encode($payload);
$payload = Json::encode($payload);
break;
}