File: test.minify.html

package info (click to toggle)
node-jsonminify 0.4.1+dfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 128 kB
  • sloc: makefile: 23
file content (110 lines) | stat: -rw-r--r-- 2,438 bytes parent folder | download | duplicates (2)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Test JSON.minify()</title>

<script type="text/javascript" src="minify.json.js"></script>

</head>

<body onload="check()">
<h1>Test JSON.minify()</h1>

<pre>console.log views.</pre>

<p>test #1</p>
<textarea id="orig_json1" cols="50" rows="12">
// this is a JSON file with comments
{
	"foo": "bar",	// this is cool
	"bar": [
		"baz", "bum", "zam"
	],
/* the rest of this document is just fluff
   in case you are interested. */
	"something": 10,
	"else": 20
}

/* NOTE: You can easily strip the whitespace and comments 
   from such a file with the JSON.minify() project hosted 
   here on github at http://github.com/getify/JSON.minify 
*/
</textarea>
<p>result #1</p>
<textarea id="new_json1" cols="50" rows="12"></textarea>


<p>test #2</p>
<textarea id="orig_json2" cols="50" rows="12">

{"/*":"*/","//":"",/*"//"*/"/*/"://
"//"}

</textarea>
<p>result #2</p>
<textarea id="new_json2" cols="50" rows="12"></textarea>


<p>test #3</p>
<textarea id="orig_json3" cols="50" rows="12">
/*
this is a 
multi line comment */{

"foo"
:
	"bar/*"// something
	,	"b\"az":/*
something else */"blah"

}
</textarea>
<p>result #3</p>
<textarea id="new_json3" cols="50" rows="12"></textarea>


<p>test #4</p>
<textarea id="orig_json4" cols="50" rows="12">
{"foo": "ba\"r//", "bar\\": "b\\\"a/*z", 
	"baz\\\\": /* yay */ "fo\\\\\"*/o" 
}
</textarea>
<p>result #4</p>
<textarea id="new_json4" cols="50" rows="12"></textarea>


<p>test #5</p>
<textarea id="orig_json5" cols="50" rows="12">
/** a */[{"foo": "ba\"r//", "bar\\": "b\\\"a/*z",
	"baz\\\\": /* yay */ "fo\\\\\"*/o",
	"spa\\\\m": /* aja*/ [ { "a": [1,2,3,4]}, {"b": 2}]
} /** aa */] //aaaa\n//aaaa
</textarea>
<p>result #5</p>
<textarea id="new_json5" cols="50" rows="12"></textarea>


<button	name="check" onclick="check()">check!!</button>

<script type="text/javascript">

	function check() {
		var old;
		for (var i = 1; i <= 5; i++) {
			old = document.getElementById("orig_json" + i).value;
			var minify = JSON.minify(old);
			try {
				console.log("index:", i);
				console.log(JSON.parse(minify));
			} catch(e) {
				console.error(e);
			}
			document.getElementById("new_json" + i).value = minify;
		}
	}
</script>

</body>
</html>