1 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2 <html xmlns=
"http://www.w3.org/1999/xhtml">
4 <meta http-equiv=
"Content-Type" content=
"text/html; charset=utf-8" />
5 <title>Test JSON.minify()
</title>
7 <script type=
"text/javascript" src=
"json2.js"></script>
8 <script type=
"text/javascript" src=
"minify.json.js"></script>
13 <h1>Test JSON.minify()
</h1>
16 <textarea id=
"orig_json1" cols=
"50" rows=
"12">
17 // this is a JSON file with comments
19 "foo": "bar", // this is cool
23 /* the rest of this document is just fluff
24 in case you are interested. */
29 /* NOTE: You can easily strip the whitespace and comments
30 from such a file with the JSON.minify() project hosted
31 here on github at http://github.com/getify/JSON.minify
35 <textarea id=
"new_json1" cols=
"50" rows=
"12"></textarea>
39 <textarea id=
"orig_json2" cols=
"50" rows=
"12">
41 {"/*":"*/","//":"",/*"//"*/"/*/"://
46 <textarea id=
"new_json2" cols=
"50" rows=
"12"></textarea>
50 <textarea id=
"orig_json3" cols=
"50" rows=
"12">
53 multi line comment */{
59 something else */"blah"
64 <textarea id=
"new_json3" cols=
"50" rows=
"12"></textarea>
68 <textarea id=
"orig_json4" cols=
"50" rows=
"12">
69 {"foo": "ba\"r//", "bar\\": "b\\\"a/*z",
70 "baz\\\\": /* yay */ "fo\\\\\"*/o"
74 <textarea id=
"new_json4" cols=
"50" rows=
"12"></textarea>
78 <script type=
"text/javascript">
81 for (var i=
1; i<=
4; i++) {
82 old = document.getElementById("orig_json"+i).value;
83 document.getElementById("new_json"+i).value = JSON.minify(old);