Created
March 9, 2017 20:07
-
-
Save JakeConway/6a944f524a5636ec9e9df2acfd76eac9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var styleJSON = JSON.stringify(success.data).split(","); | |
for(var i = 0; i < styleJSON.length; i++) { | |
styleJSON[i] = styleJSON[i].split(":"); | |
var innerLength = styleJSON[i].length; | |
for(var j = 0; j < innerLength; j++) { | |
if(styleJSON[i][j].indexOf("[{") > -1) { | |
styleJSON[i][j] = styleJSON[i][j].split("{"); | |
styleJSON[i][j][0] = "<span style='color: #660000;'>" + "[" + "</span>" + "<br>" + | |
"<span style='color: #660000;'>" + "{" + "</span>" + "<br>"; | |
styleJSON[i][j][1] = "<span style='color: #006699;'>" + styleJSON[i][j][1] + "</span>" + ": "; | |
var moreInnerLength = styleJSON[i][j].length; | |
for (var k = 2; k < moreInnerLength; k++) { | |
styleJSON[i][j][k] = "<span style='color: #88F;'>" + styleJSON[i][j][k] + "</span>" + | |
"<span style='color:#88F;'>, </span>"; | |
} | |
styleJSON[i][j] = styleJSON[i][j].join(""); | |
continue; | |
} | |
if(styleJSON[i][j].indexOf("{") > -1) { | |
styleJSON[i][j] = styleJSON[i][j].split("{"); | |
styleJSON[i][j][0] = "<span style='color: #660000;'>" + "{" + "</span>" + "<br>"; | |
styleJSON[i][j][1] = "<span style='color: #006699;'>" + styleJSON[i][j][1] + "</span>" + ": "; | |
var moreInnerLength = styleJSON[i][j].length; | |
for (var k = 2; k < moreInnerLength; k++) { | |
styleJSON[i][j][k] = "<span style='color: #88F;'>" + styleJSON[i][j][k] + "</span>" + | |
"<span style='color:#88F;'>, </span>"; | |
} | |
styleJSON[i][j] = styleJSON[i][j].join(""); | |
continue; | |
} | |
if(styleJSON[i][j].indexOf("}]") > -1) { | |
styleJSON[i][j] = styleJSON[i][j].split("}"); | |
styleJSON[i][j][styleJSON[i][j].length-1] = "<br>" + "<span style='color: #660000;'>" + "}" + "</span>" + | |
"<br>" + "<span style='color: #660000'>" + "]" + "</span>" + "<br>"; | |
styleJSON[i][j][styleJSON[i][j].length-2] = "<span style='color: #88F;'>" + styleJSON[i][j][styleJSON[i][j].length-2] + "</span>"; | |
moreInnerLength = styleJSON[i][j].length-2; | |
for (k = 0; k < moreInnerLength; k++) { | |
styleJSON[i][j][k] = "<span style='color: #88F;'>" + styleJSON[i][j][k] + "</span>" + | |
"<span style='color: #660000;'>, </span>" | |
} | |
styleJSON[i][j] = styleJSON[i][j].join(""); | |
continue; | |
} | |
if(styleJSON[i][j].indexOf("}") > -1) { | |
styleJSON[i][j] = styleJSON[i][j].split("}"); | |
styleJSON[i][j][styleJSON[i][j].length-1] = "<br>" + "<span style='color: #660000;'>" + "}" + "</span>" + "<br>"; | |
styleJSON[i][j][styleJSON[i][j].length-2] = "<span style='color: #88F;'>" + styleJSON[i][j][styleJSON[i][j].length-2] + "</span>"; | |
moreInnerLength = styleJSON[i][j].length-2; | |
for (k = 0; k < moreInnerLength; k++) { | |
styleJSON[i][j][k] = "<span style='color: #88F;'>" + styleJSON[i][j][k] + "</span>" + | |
"<span style='color: #660000;'>, </span>" | |
} | |
styleJSON[i][j] = styleJSON[i][j].join(""); | |
continue; | |
} | |
if (styleJSON[i][j].indexOf("{") == -1 && styleJSON[i][j].indexOf("}") == -1) { | |
if (j == 0) { | |
styleJSON[i][j] = "<span style='color: #006699;'>" + styleJSON[i][j] + "</span>" + ": "; | |
} | |
else { | |
styleJSON[i][j] = "<span style='color: #88F;'>" + styleJSON[i][j] + "</span>" + | |
"<span style='color:#88F;'>, </span>"; | |
} | |
continue; | |
} | |
} | |
styleJSON[i] = styleJSON[i].join(""); | |
} | |
styleJSON.unshift("<pre>"); | |
styleJSON.push("</pre>"); | |
styleJSON = styleJSON.join(""); | |
console.log(JSON.stringify(styleJSON).replace(/\\"/g, '"')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment