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
| <html> <head> <title>json</title> </head> <body> <script> var formatArrString = function(conf) { let html = ""; let tmp = ""; let level = 0; let num = 4; for(let i=0;i<conf.length;i++) { tmp += conf.charAt(i); if(conf.charAt(i) == '[' && conf.charAt(i+1) == '[') { html += tmp; html += "<br>"; level += num; tmp = ""; for(let j=0;j<level;j++) html += "\xa0" }
if(conf.charAt(i) == ',' && conf.charAt(i+1) == '[') { html += tmp; html += "<br>"; level += num; tmp = ""; for(let j=0;j<level;j++) html += "\xa0" }
if(conf.charAt(i) == ']' && conf.charAt(i+1) == ',') { html += tmp; tmp = ""; level -= num; } else if(conf.charAt(i) == ']' && conf.charAt(i+1) == ']') { html += tmp; tmp = ""; html += "<br>"; level -= num; for(let j=0;j<level;j++) html += "\xa0" } } html += tmp; return html; }
var conf = "[[667,3,[[99999999999,10900,[[99999999999,20000000,1000],[20000000,10000000,900],[10000000,5000000,800],[5000000,1000000,700]]],[10900,10600,[[99999999999,20000000,900],[20000000,10000000,800],[10000000,5000000,700],[5000000,1000000,600]]],[10600,10300,[[99999999999,20000000,800],[20000000,10000000,700],[10000000,5000000,600],[5000000,1000000,500]]],[10300,10000,[[99999999999,20000000,700],[20000000,10000000,600],[10000000,5000000,500],[5000000,1000000,400]]],[9000,7000,[[-99999999999,-20000000,-250],[-20000000,-10000000,-200],[-10000000,-5000000,-200],[-5000000,-1000000,-200]]],[7000,0,[[-99999999999,-20000000,-300],[-20000000,-10000000,-200],[-10000000,-5000000,-200],[-5000000,-1000000,-200]]]]],[2405,3,[[99999999999,10900,[[99999999999,20000000,1000],[20000000,10000000,900],[10000000,5000000,800],[5000000,1000000,700]]],[10900,10600,[[99999999999,20000000,900],[20000000,10000000,800],[10000000,5000000,700],[5000000,1000000,600]]],[10600,10300,[[99999999999,20000000,800],[20000000,10000000,700],[10000000,5000000,600],[5000000,1000000,500]]],[10300,10000,[[99999999999,20000000,700],[20000000,10000000,600],[10000000,5000000,500],[5000000,1000000,400]]],[9000,7000,[[-99999999999,-20000000,-250],[-20000000,-10000000,-200],[-10000000,-5000000,-200],[-5000000,-1000000,-200]]],[7000,0,[[-99999999999,-20000000,-300],[-20000000,-10000000,-200],[-10000000,-5000000,-200],[-5000000,-1000000,-200]]]]]]"; document.write(formatArrString(conf)); </script> </body> </html>
|