Rev | Line | |
---|
[483] | 1 | <html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" > |
---|
| 2 | <head> |
---|
| 3 | <title>Beautify JSON</title> |
---|
| 4 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
---|
| 5 | <style type="text/css"> |
---|
| 6 | @import "../../../dojo/resources/dojo.css"; |
---|
| 7 | @import "../../../dijit/tests/css/dijitTests.css"; |
---|
| 8 | </style> |
---|
| 9 | <script type="text/javascript" src="../../../dojo/dojo.js" data-dojo-config="isDebug: true"></script> |
---|
| 10 | <script type="text/javascript"> |
---|
| 11 | |
---|
| 12 | trimPath = function(o){ |
---|
| 13 | if(o instanceof Array){ |
---|
| 14 | for(var i = 0; i < o.length; ++i){ |
---|
| 15 | trimPath(o[i]); |
---|
| 16 | } |
---|
| 17 | return; |
---|
| 18 | } |
---|
| 19 | if(("shape" in o) && ("path" in o.shape)){ |
---|
| 20 | o.shape.path = dojo.trim(o.shape.path.replace(/\s\s+/g, " ")); |
---|
| 21 | } |
---|
| 22 | if("children" in o){ |
---|
| 23 | trimPath(o.children); |
---|
| 24 | } |
---|
| 25 | }; |
---|
| 26 | |
---|
| 27 | beautify = function(){ |
---|
| 28 | var t = dojo.byId("io"); |
---|
| 29 | var v = dojo.fromJson(t.value); |
---|
| 30 | if(dojo.byId("path").checked){ |
---|
| 31 | trimPath(v); |
---|
| 32 | } |
---|
| 33 | t.value = dojo.toJson(v, dojo.byId("pprint").checked); |
---|
| 34 | }; |
---|
| 35 | |
---|
| 36 | </script> |
---|
| 37 | </head> |
---|
| 38 | <body> |
---|
| 39 | <h1>Beautify JSON</h1> |
---|
| 40 | <p>Paste valid JSON in this textarea and receive a pretty-printed version of it. Use Firefox, if you want to be able to read comma-ended sequences (Python style). |
---|
| 41 | Additionally it knows how to remove extra spaces from path elements.</p> |
---|
| 42 | <p><textarea id="io" cols="80" rows="10" wrap="off"></textarea></p> |
---|
| 43 | <p><button onclick="beautify()">Beautify!</button> |
---|
| 44 | <input type="checkbox" id="path" checked="checked" /> Process "path" elements |
---|
| 45 | <input type="checkbox" id="pprint" checked="checked" /> Pretty-print JSON</p> |
---|
| 46 | <p><em>This program is a companion for inspector.html.</em></p> |
---|
| 47 | </body> |
---|
| 48 | </html> |
---|
Note: See
TracBrowser
for help on using the repository browser.