I want to add a newline after each key value pair in an object using JSON.stringify()
In my actual code I will be getting a lot of key value pairs and having the new lines makes it easier to read.
Example code is:
let test = {'key' : ['one', 'two', 'three'], 'keyTwo' : ['one', 'two', 'three']}
let testOne = JSON.stringify(test, null, 't')
console.log(testOne)
outputs:
{
"key": [
"one",
"two",
"three"
],
"keyTwo": [
"one",
"two",
"three"
]
}
I want:
{
"key": [
"one",
"two",
"three"
],
<----- newline here
"keyTwo": [
"one",
"two",
"three"
]
}
I have tried
let test = {'key' : ['one', 'two', 'three'] + "\n", 'keyTwo' : ['one', 'two', 'three']+ "\n"}
let testOne = JSON.stringify(test, null, 'tn')
console.log(testOne);
Neither work