My list currently consists of objects with the following structure:
[ Person({ getName: Function, id: '310394', age: 30 }), Person({ getName: Function, id: '244454', age: 31 })...]
Now, I am looking to transform it into this format:
{
peopleIds: [
244454,244454...
]
}
I attempted the following method:
public makePeopleIdJSON(list: Person[]):void {
list.forEach(x => console.log(x.id))
}
This code only logs the id for each object in the list. How can I convert this output into a JSON in the requested format?
Thank you very much.