Я не думаю, что у вас есть рекурсивная структура данных, поэтому рекурсия не помогла бы, но вам нужно просмотреть данные и выбрать то, что вам нужно, как вы сказали. Основная проблема в том, чтобы узнать, какие данные вам нужны и как их найти.
Я думаю, это может дать вам представление о том, чего вы пытаетесь достичь,
// If there are multiple items inside qPivotDataPages you'll need to loop
// over those and call process for each one, then join the resulting arrays.
const data = json.qPivotDataPages[0].qLeft;
const result = process(data);
function process(input) {
const [team1, team2] = input;
const team1Results = processTeam(team1);
const team2Results = processTeam(team2);
return [...team1Results, ...team2Results];
}
function processTeam(teamData) {
const teamResults = [];
const teamName = teamData.qText;
const halfDatas = teamData.qSubNodes.filter((item) => item.qText === '1ª' || item.qText === '2ª' || item.qText === 'InCia' );
halfDatas.forEach((halfData) => {
const half = halfData.qText;
halfData.qSubNodes.forEach((item) => {
if (item.qText === 'MI' || item.qText === 'ME') {
teamResults.push({
team: teamName,
half: half,
type: item.qText,
});
}
});
});
return teamResults;
}