Not able to show deeply nested JSON Objects to show up.Have been looking at all kinds of stackoverflow posts for this. Appreciate any help on this newbie question. I want it to show details of the athlete JSONObject within the athletes array. It shows up like [Object].
eventUnitResults: [ { is_team: true, athletes: [ [Object], [Object] ] },
{ is_team: true, athletes: [ [Object], [Object] ] } ]
const result = {}
let eventUnitResults = [];
let athletes = [];
for (i=0; i < 2; i++) {
const athlete = {};
athlete.athlete_name = 'Ram' + i;
athlete.athlete_gender = 'M'
athletes.push(athlete);
}
for (j=0;j < 2;j++) {
const nestedResult = {};
nestedResult.is_team = true;
if (athletes) {
nestedResult.athletes = athletes;
}
console.log('nestedResult:', nestedResult);
if (nestedResult) {
eventUnitResults.push(nestedResult);//TODO:
//eventUnitResults.push(JSON.stringify(nestedResult));//TODO:
}
}
console.log('eventUnitResults:', eventUnitResults);//<==== how can I get deeply nested values of athletes showing up properly here
if (eventUnitResults) {
result.event_unit_results = eventUnitResults;
}
console.log('result:', result)
TIA