Formatted JSON Output
Feb 16, 2023
Did you know that you can see the JSON in a proper format using JSON.stringify(object,null,’\t’)
For Example: following code will print the JSON in a formatted manner
var top5Cars = {
"Top 5 Cars": [
{
"Make": "Toyota",
"Model": "Corolla",
"Year": "2022"
},
{
"Make": "Honda",
"Model": "Civic",
"Year": "2022"
},
{
"Make": "Tesla",
"Model": "Model 3",
"Year": "2022"
},
{
"Make": "Ford",
"Model": "Mustang",
"Year": "2022"
},
{
"Make": "Chevrolet",
"Model": "Silverado",
"Year": "2022"
}
]
}
gs.info(JSON.stringify(top5Cars,null,'\t'))
Result: