Is it possible to stringify the following into the expected output?
Input:
let output = JSON.stringify([
{
"Color": "Red",
"Type":"Fast"
},
{
"Color": "Blue",
"Type":"Slow"
}
]);
Expected output:
[
{"Color": "Red", "Type":"Fast"},
{"Color": "Blue", "Type":"Slow"}
]
You can try mapping through each item individually and stringifying, then joining together by a linebreak:
const arr = [
{"Color": "Red", "Type":"Fast"},
{"Color": "Blue", "Type":"Slow"}
];
const result = "[\n" + arr.map(e => ' ' + JSON.stringify(e)).join(',\n') + "\n]";
console.log(result)