remove legacy json format function (#12583)

* remove legacy json format function

* remove silly use
This commit is contained in:
Tony Murray
2021-03-04 07:55:41 -06:00
committed by GitHub
parent e4e2113585
commit 6e19805bcb
65 changed files with 84 additions and 206 deletions

View File

@@ -624,7 +624,7 @@ class ModuleTestHelper
}
}
file_put_contents($this->json_file, _json_encode($existing_data) . PHP_EOL);
file_put_contents($this->json_file, json_encode($existing_data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . PHP_EOL);
$this->qPrint("Saved to $this->json_file\nReady for testing!\n");
}

View File

@@ -1107,128 +1107,6 @@ function validate_device_id($id)
return $return;
}
// The original source of this code is from Stackoverflow (www.stackoverflow.com).
// http://stackoverflow.com/questions/6054033/pretty-printing-json-with-php
// Answer provided by stewe (http://stackoverflow.com/users/3202187/ulk200
if (! defined('JSON_UNESCAPED_SLASHES')) {
define('JSON_UNESCAPED_SLASHES', 64);
}
if (! defined('JSON_PRETTY_PRINT')) {
define('JSON_PRETTY_PRINT', 128);
}
if (! defined('JSON_UNESCAPED_UNICODE')) {
define('JSON_UNESCAPED_UNICODE', 256);
}
function _json_encode($data, $options = 448)
{
if (version_compare(PHP_VERSION, '5.4', '>=')) {
return json_encode($data, $options);
} else {
return _json_format(json_encode($data), $options);
}
}
function _json_format($json, $options = 448)
{
$prettyPrint = (bool) ($options & JSON_PRETTY_PRINT);
$unescapeUnicode = (bool) ($options & JSON_UNESCAPED_UNICODE);
$unescapeSlashes = (bool) ($options & JSON_UNESCAPED_SLASHES);
if (! $prettyPrint && ! $unescapeUnicode && ! $unescapeSlashes) {
return $json;
}
$result = '';
$pos = 0;
$strLen = strlen($json);
$indentStr = ' ';
$newLine = "\n";
$outOfQuotes = true;
$buffer = '';
$noescape = true;
for ($i = 0; $i < $strLen; $i++) {
// Grab the next character in the string
$char = substr($json, $i, 1);
// Are we inside a quoted string?
if ('"' === $char && $noescape) {
$outOfQuotes = ! $outOfQuotes;
}
if (! $outOfQuotes) {
$buffer .= $char;
$noescape = '\\' === $char ? ! $noescape : true;
continue;
} elseif ('' !== $buffer) {
if ($unescapeSlashes) {
$buffer = str_replace('\\/', '/', $buffer);
}
if ($unescapeUnicode && function_exists('mb_convert_encoding')) {
// http://stackoverflow.com/questions/2934563/how-to-decode-unicode-escape-sequences-like-u00ed-to-proper-utf-8-encoded-cha
$buffer = preg_replace_callback(
'/\\\\u([0-9a-f]{4})/i',
function ($match) {
return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
},
$buffer
);
}
$result .= $buffer . $char;
$buffer = '';
continue;
} elseif (false !== strpos(" \t\r\n", $char)) {
continue;
}
if (':' === $char) {
// Add a space after the : character
$char .= ' ';
} elseif (('}' === $char || ']' === $char)) {
$pos--;
$prevChar = substr($json, $i - 1, 1);
if ('{' !== $prevChar && '[' !== $prevChar) {
// If this character is the end of an element,
// output a new line and indent the next line
$result .= $newLine;
for ($j = 0; $j < $pos; $j++) {
$result .= $indentStr;
}
} else {
// Collapse empty {} and []
$result = rtrim($result) . "\n\n" . $indentStr;
}
}
$result .= $char;
// If the last character was the beginning of an element,
// output a new line and indent the next line
if (',' === $char || '{' === $char || '[' === $char) {
$result .= $newLine;
if ('{' === $char || '[' === $char) {
$pos++;
}
for ($j = 0; $j < $pos; $j++) {
$result .= $indentStr;
}
}
}
// If buffer not empty after formating we have an unclosed quote
if (strlen($buffer) > 0) {
//json is incorrectly formatted
$result = false;
}
return $result;
}
function convert_delay($delay)
{
$delay = preg_replace('/\s/', '', $delay);

View File

@@ -26,7 +26,7 @@ if (! Auth::check()) {
'status' => 'error',
'message' => 'Unauthenticated',
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
@@ -49,4 +49,4 @@ $response = [
'dashboard_id' => $dash_id,
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -85,4 +85,4 @@ if (isset($vars['template']) && empty(view(['template' => $vars['template']], []
$response = ['status' => $status, 'message' => $message, 'newid' => $template_newid];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -51,4 +51,4 @@ if (! Auth::user()->hasGlobalAdmin()) {
}
}
header('Content-Type: application/json');
echo _json_encode($status);
echo json_encode($status, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -7,7 +7,7 @@ if (! Auth::user()->hasGlobalAdmin()) {
'status' => 'error',
'message' => 'Need to be admin',
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
@@ -79,4 +79,4 @@ $response = [
'status' => $status,
'message' => $message,
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -45,4 +45,4 @@ if (is_numeric($service_id) && $service_id > 0) {
}
}
header('Content-Type: application/json');
echo _json_encode($status);
echo json_encode($status, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -7,7 +7,7 @@ if (! Auth::user()->hasGlobalAdmin()) {
'status' => 'error',
'message' => 'Need to be admin',
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}

View File

@@ -37,4 +37,4 @@ if (! Auth::user()->hasGlobalAdmin()) {
}
}
header('Content-Type: application/json');
echo _json_encode($status);
echo json_encode($status, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -7,7 +7,7 @@ if (! Auth::user()->hasGlobalAdmin()) {
'status' => 'error',
'message' => 'Need to be admin',
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}

View File

@@ -26,7 +26,7 @@ if (! Auth::check()) {
'status' => 'error',
'message' => 'Unauthenticated',
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
@@ -52,4 +52,4 @@ $response = [
'message' => $message,
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -37,4 +37,4 @@ if (! Auth::user()->hasGlobalAdmin()) {
}
}
header('Content-Type: application/json');
echo _json_encode($status);
echo json_encode($status, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -25,4 +25,4 @@ if (! Auth::user()->hasGlobalAdmin()) {
}
}
header('Content-Type: application/json');
echo _json_encode($status);
echo json_encode($status, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -44,4 +44,4 @@ $response = [
'message' => $message,
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -108,4 +108,4 @@ if (! Auth::user()->hasGlobalAdmin()) {
}
header('Content-Type: application/json');
echo _json_encode($status);
echo json_encode($status, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -19,7 +19,7 @@ if (! Auth::user()->hasGlobalAdmin()) {
'status' => 'error',
'message' => 'Need to be admin',
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
@@ -50,4 +50,4 @@ $response = [
'message' => $message,
'extra' => $extra,
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -19,7 +19,7 @@ if (! Auth::user()->hasGlobalAdmin()) {
'status' => 'error',
'message' => 'Need to be admin',
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
@@ -45,4 +45,4 @@ $response = [
'status' => $status,
'message' => $message,
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -54,4 +54,4 @@ foreach (dbFetchRows('SELECT `id`,`rule`,`name` FROM `alert_rules` order by `nam
$output['rules'] = $rules;
header('Content-type: application/json');
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -5,7 +5,7 @@ if (! Auth::user()->hasGlobalAdmin()) {
'status' => 'error',
'message' => 'Need to be admin',
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
$customoid_id = $_POST['customoid_id'];

View File

@@ -26,5 +26,5 @@ if (is_numeric($group_id) && $group_id > 0) {
'descr' => $group['descr'],
];
header('Content-type: application/json');
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}

View File

@@ -33,5 +33,5 @@ if (is_numeric($service_id) && $service_id > 0) {
];
header('Content-Type: application/json');
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}

View File

@@ -19,7 +19,7 @@ if (! Auth::user()->hasGlobalAdmin()) {
'status' => 'error',
'message' => 'Need to be admin',
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
@@ -50,4 +50,4 @@ $response = [
'message' => $message,
'extra' => $extra,
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -17,7 +17,7 @@ if (! Auth::user()->hasGlobalAdmin()) {
'status' => 'error',
'message' => 'Need to be admin',
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
@@ -65,4 +65,4 @@ $output = [
];
header('Content-type: application/json');
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -32,4 +32,4 @@ $output = [
];
header('Content-type: application/json');
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -23,4 +23,4 @@ $output = [
'message' => $message,
];
header('Content-type: application/json');
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -30,7 +30,7 @@ if (! Auth::user()->hasGlobalAdmin()) {
'status' => 'error',
'message' => 'Need to be admin',
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
@@ -70,4 +70,4 @@ $output = [
];
header('Content-type: application/json');
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -19,7 +19,7 @@ if (! Auth::user()->hasGlobalAdmin()) {
'status' => 'error',
'message' => 'Need to be admin',
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
@@ -48,4 +48,4 @@ $response = [
'message' => $message,
'extra' => $extra,
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -219,4 +219,4 @@ if ($sub_type == 'new-maintenance') {
];
}//end if
header('Content-type: application/json');
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -22,9 +22,9 @@ if (isset($parameters)) {
} else {
$message = 'ERROR: Could not query';
}
echo display(_json_encode([
'status' => $status,
'message' => $message,
'search_in_conf_textbox' => $parameters,
'output' => $output,
]));
echo display(json_encode([
'status' => $status,
'message' => $message,
'search_in_conf_textbox' => $parameters,
'output' => $output,
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));

View File

@@ -20,7 +20,7 @@ if (! Auth::user()->hasGlobalAdmin()) {
'status' => 'error',
'message' => 'Need to be admin',
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
@@ -51,4 +51,4 @@ $response = [
'status' => $status,
'message' => $message,
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -20,7 +20,7 @@ if (! Auth::user()->hasGlobalAdmin()) {
'status' => 'error',
'message' => 'Need to be admin',
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
@@ -60,4 +60,4 @@ $response = [
'status' => $status,
'message' => $message,
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -20,7 +20,7 @@ if (! Auth::user()->hasGlobalAdmin()) {
'status' => 'error',
'message' => 'Need to be admin',
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
@@ -50,4 +50,4 @@ $response = [
'status' => $status,
'message' => $message,
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -19,7 +19,7 @@ if (! Auth::user()->hasGlobalAdmin()) {
'status' => 'error',
'message' => 'Need to be admin',
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
@@ -50,4 +50,4 @@ $response = [
'message' => $message,
'extra' => $extra,
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -7,7 +7,7 @@ if (! Auth::check()) {
'status' => 'error',
'message' => 'Unauthenticated',
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
@@ -76,4 +76,4 @@ $response = [
'message' => $message,
'extra' => $extra,
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -44,4 +44,4 @@ if (! empty($ifName) && is_numeric($port_id)) {
$response = [
'status' => $status,
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -54,4 +54,4 @@ if (! empty($ifName) && is_numeric($port_id) && is_numeric($port_id)) {
$response = [
'status' => $status,
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -7,7 +7,7 @@ if (! Auth::user()->hasGlobalAdmin()) {
'status' => 'error',
'message' => 'Need to be admin',
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
@@ -78,4 +78,4 @@ $response = [
'status' => $status,
'message' => $message,
];
echo _json_encode($response);
echo json_encode($response, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -71,7 +71,7 @@ $query = "SELECT DATE_FORMAT(time_logged, '" . \LibreNMS\Config::get('alert_grap
}
}
$graph_data = _json_encode($data);
$graph_data = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
?>
var groups = new vis.DataSet();
<?php

View File

@@ -114,4 +114,4 @@ $output = [
'rows' => $response,
'total' => $total,
];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -83,4 +83,4 @@ $output = [
'rows' => $response,
'total' => $total,
];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -118,4 +118,4 @@ $output = [
'rows' => $response,
'total' => $total,
];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -188,4 +188,4 @@ $output = [
'rows' => $response,
'total' => $total,
];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -105,4 +105,4 @@ $output = [
'rows' => $response,
'total' => $count,
];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -112,4 +112,4 @@ $output = [
'rows' => $response,
'total' => $total,
];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -50,4 +50,4 @@ $output = [
'rows' => $response,
'total' => $total,
];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -173,4 +173,4 @@ foreach (dbFetchRows($sql, $param) as $bill) {
}
$output = ['current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => $total];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -65,4 +65,4 @@ $output = [
'rows' => $response,
'total' => count($COMPONENTS[$device_id]),
];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -83,4 +83,4 @@ $output = [
'rows' => $response,
'total' => $total,
];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -99,4 +99,4 @@ $output = [
'rows' => $response,
'total' => $total,
];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -97,4 +97,4 @@ if (empty($messages['total_results'])) {
}
$output = ['current'=>$current, 'rowCount'=>$rowCount, 'rows'=>$response, 'total'=>$total];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -83,4 +83,4 @@ $output = [
'rows' => $response,
'total' => $total,
];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -68,4 +68,4 @@ $output = [
'rows' => $response,
'total' => $total,
];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -88,4 +88,4 @@ $output = [
'rows' => $response,
'total' => $total,
];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -49,4 +49,4 @@ foreach (dbFetchRows($sql, $param) as $drive) {
}
$output = ['current'=>$current, 'rowCount'=>$rowCount, 'rows'=>$response, 'total'=>$total];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -205,4 +205,4 @@ $output = [
'total' => $total,
];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -49,4 +49,4 @@ foreach (dbFetchRows($sql, $param) as $drive) {
}
$output = ['current'=>$current, 'rowCount'=>$rowCount, 'rows'=>$response, 'total'=>$total];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -100,4 +100,4 @@ $output = [
'rows' => $response,
'total' => $total,
];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -58,4 +58,4 @@ foreach (dbFetchRows($sql, $param) as $routing) {
}
$output = ['current'=>$current, 'rowCount'=>$rowCount, 'rows'=>$response, 'total'=>$total];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -163,4 +163,4 @@ $output = [
'rows' => $response,
'total' => $count,
];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -53,4 +53,4 @@ foreach (dbFetchRows($sql, $param) as $drive) {
}
$output = ['current'=>$current, 'rowCount'=>$rowCount, 'rows'=>$response, 'total'=>$total];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -113,4 +113,4 @@ $output = [
'rows' => $response,
'total' => $count,
];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -54,4 +54,4 @@ $output = [
'rows' => $response,
'total' => $total,
];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -106,5 +106,5 @@ if (isset($vars['device_id'])) {
'rows' => $response,
'total' => $total,
];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
}

View File

@@ -108,4 +108,4 @@ $output = [
'rows' => $response,
'total' => $count,
];
echo _json_encode($output);
echo json_encode($output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

View File

@@ -150,7 +150,7 @@ function poll_service($service)
foreach ($perf as $k => $v) {
$DS[$k] = $v['uom'];
}
d_echo('Service DS: ' . _json_encode($DS) . "\n");
d_echo('Service DS: ' . json_encode($DS, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) . "\n");
if (($service['service_ds'] == '{}') || ($service['service_ds'] == '')) {
$update['service_ds'] = json_encode($DS);
}