In my Vue application I have a list of objects looking like this:
const arr = [ { id: 1, name: 'Max', grade: 3 }, { id: 2, name: 'Lisa', grade: 2 } ];
Now I want every Object in this array to be a single string for itself. I know there is JSON.stringifty but this makes my whole array to a string and not every single object.
So the result should be something like:
const arr = ["{id:1,name:'Max',grade:3}", "{id:2,name:'Max',grade:3}"]
CodePudding user response:
That would be
const myJsonArr = arr.map((v) => JSON.stringify(v))
CodePudding user response:
you can try it
let array = arr.map(item=>JSON.stringify())
CodePudding user response:
Yes, you can use JSON.stringify(YOUR_OBJECT) to parse your object into string. You can refer this question.