-
-
Save ivanionut/8d77bb31e779944a635084a0b5a9af04 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
<cfscript> | |
function prettyPrintJSON (inputJSON) { | |
var engine = createObject("java","javax.script.ScriptEngineManager").init().getEngineByName("nashorn"); | |
engine.eval(" | |
function prettyPrintJSON (data) { | |
return JSON.stringify(JSON.parse(data), null, '\t'); | |
} | |
"); | |
return engine.invokeFunction("prettyPrintJSON", [inputJSON]); | |
} | |
</cfscript> | |
<cfsavecontent variable="myJSON"> | |
{"a":1,"b":"foo","c":[true,false,null,"null",{"d":{"e":130000,"f":1.3e5}}]} | |
</cfsavecontent> | |
<cfoutput> | |
<textarea style="width:100%; height: 100%">#prettyPrintJSON(myJSON)#</textarea> | |
</cfoutput> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment