-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtest.php
More file actions
51 lines (42 loc) · 1.01 KB
/
test.php
File metadata and controls
51 lines (42 loc) · 1.01 KB
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
47
48
49
50
<?php
require 'tidyjson.php';
function dump($str) {
echo "<pre>" . htmlentities($str) . "</pre>\n";
}
$json = <<<EOF
{
"glossary": {
"title": "example glossary",
"GlossDiv": {
"title": "S",
"GlossList": {
"GlossEntry": {
"ID": "SGML",
"SortAs": "SGML",
"GlossTerm": "Standard Generalized Markup Language",
"Acronym": "SGML",
"Abbrev": "ISO 8879:1986",
"GlossDef": {
"para": "A meta-markup language, used to create markup languages such as DocBook.",
"GlossSeeAlso": ["GML", "XML"]
},
"GlossSee": "markup"
}
}
}
}
}
EOF;
echo "Original: ";
dump($json);
$tidy = TidyJSON::tidy($json);
echo "Tidy: ";
dump($tidy);
$compressed = json_encode(json_decode($json));
echo "Compressed w/ PHP: ";
dump($compressed);
$tidy = TidyJSON::tidy($compressed);
echo "Re-tidied: ";
dump($tidy);
echo "<hr /><h3>Sourcecode:</h3>";
highlight_file(__FILE__);