5c7460d3636c11f09548db30c5fd741376168c51.svn-base 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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" djConfig="isDebug: true"></script>
  10. <script type="text/javascript">
  11. trimPath = function(o){
  12. if(o instanceof Array){
  13. for(var i = 0; i < o.length; ++i){
  14. trimPath(o[i]);
  15. }
  16. return;
  17. }
  18. if(("shape" in o) && ("path" in o.shape)){
  19. o.shape.path = dojo.trim(o.shape.path.replace(/\s\s+/g, " "));
  20. }
  21. if("children" in o){
  22. trimPath(o.children);
  23. }
  24. };
  25. beautify = function(){
  26. var t = dojo.byId("io");
  27. var v = dojo.fromJson(t.value);
  28. if(dojo.byId("path").checked){
  29. trimPath(v);
  30. }
  31. t.value = dojo.toJson(v, dojo.byId("pprint").checked);
  32. };
  33. </script>
  34. </head>
  35. <body>
  36. <h1>Beautify JSON</h1>
  37. <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).
  38. Additionally it knows how to remove extra spaces from path elements.</p>
  39. <p><textarea id="io" cols="80" rows="10" wrap="off"></textarea></p>
  40. <p><button onclick="beautify()">Beautify!</button>
  41. &nbsp;&nbsp;&nbsp;<input type="checkbox" id="path" checked="checked" />&nbsp;Process "path" elements
  42. &nbsp;&nbsp;&nbsp;<input type="checkbox" id="pprint" checked="checked" />&nbsp;Pretty-print JSON</p>
  43. <p><em>This program is a companion for inspector.html.</em></p>
  44. </body>
  45. </html>