pretty json
This commit is contained in:
parent
d3b21bba1c
commit
4414b6035a
11
index.php
11
index.php
|
@ -16,6 +16,7 @@ $buttons = [
|
||||||
'qprintdecode' => 'Qprint Decode',
|
'qprintdecode' => 'Qprint Decode',
|
||||||
'hash' => 'Hash',
|
'hash' => 'Hash',
|
||||||
'hex' => 'Hex',
|
'hex' => 'Hex',
|
||||||
|
'prettyjson' => 'Pretty JSON',
|
||||||
];
|
];
|
||||||
|
|
||||||
$str = $result = $_GET['str'] ?? '';
|
$str = $result = $_GET['str'] ?? '';
|
||||||
|
@ -89,6 +90,16 @@ if ($action == 'reset') {
|
||||||
} elseif ($action == 'qprintdecode') {
|
} elseif ($action == 'qprintdecode') {
|
||||||
$result = quoted_printable_decode($str)?: $str;
|
$result = quoted_printable_decode($str)?: $str;
|
||||||
$help = 'https://www.php.net/quoted_printable_decode';
|
$help = 'https://www.php.net/quoted_printable_decode';
|
||||||
|
|
||||||
|
} elseif ($action == 'prettyjson') {
|
||||||
|
$jd = json_decode($str);
|
||||||
|
if (JSON_ERROR_NONE !== json_last_error()) {
|
||||||
|
$result = 'Error: '. json_last_error_msg() ."\n\n". $str;
|
||||||
|
} else {
|
||||||
|
$result = json_encode($jd, JSON_PRETTY_PRINT | JSON_PRESERVE_ZERO_FRACTION);
|
||||||
|
}
|
||||||
|
$help = 'https://www.php.net/json';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?><!doctype html>
|
?><!doctype html>
|
||||||
|
|
Loading…
Reference in New Issue