JSON.format(json) Last updated: 04. Jan 2023
Outputs specified JSON string to "prettified" indented JSON.
Parameters
Name | Type | Description |
---|---|---|
json | string | JSON string to format. |
Returns
Nothing, but writes text to output stream.
Example
Code example (#JS)
#JS is mixed HTML (or other text file) with inline JavaScript with # starting and ending each inline statement.#{
var object = {
"Name" : "Abcd",
"Number" : 1234
};
// Convert object to JSON string
var json = JSON.stringify(object);
// Format indent and line breaks in JSON
var pretty = JSON.format(json);
// Remove empty lines
var html = pretty.replace(chr(13), "");
// Write HTML to output
write(html);
}#
Output
The #JS code above produces the output shown below:{
"Name": "Abcd",
"Number": 1234
}