How improve readability of JSON string formatting when or after using SerializeJSON

603 views Asked by At

Using ColdFusion 10, I created a struct and returned a JSON string after using SerializeJSON.

    <cfreturn serializeJSON(stcResult)>

The string returned looks like this:

{"errors":[{"key1":"value1"},{"key2":"value2"}]} 

I want the JSON to look something like the example below. How can I format it with different indentation levels, so it is more readable?

{
    "errors":[
        {"key1":"value1"},
        {"key1":"value1"}
    ]
} 

Thanks in advance.

1

There are 1 answers

0
Echo On BEST ANSWER

I found a solution, just need to change '+' to '&' and change '&nbsp;' to ' ' or chr(32) when using CFSCRIPT.