-
Notifications
You must be signed in to change notification settings - Fork 2
/
processing.php
46 lines (39 loc) · 943 Bytes
/
processing.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php # processing.php
use json2html\Options;
use json2html\PrettyJSON;
require 'vendor/autoload.php';
require 'src/json2html/Options.php';
require 'src/json2html/PrettyJSON.php';
$error = '';
$rHtml = '';
if (!isset($_POST['json'])) {
$error = 'In _POST not found param JSON';
} else {
$json = (string)$_POST['json'];
$options = new Options();
if (isset($_POST['onlyColorize']) && $_POST['onlyColorize'] === 'on') {
$options->setIsOnlyColorize(true);
}
$engine = new PrettyJSON($options);
$engine->setJsonText($json);
if ($engine->isError()) {
$error = $engine->getError();
} else {
$rHtml = $engine->getHtml();
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Processing JSON convert result</title>
</head>
<body>
<?php if (strlen($error) > 0) : ?>
<div>Error: <?php echo($error); ?></div>
<?php else: ?>
<div><?php echo($rHtml); ?></div>
<?php endif; ?>
</body>
</html>