Дано:
[
{
"EventStartDate": "17/10/2008",
"EventType": "Restricted",
"Event": "My Forum",
"SessionStartTime": "18:00",
"City": "Ryazan",
"Type": "1on1",
"RowCount": 0
},
{
"EventStartDate": "17/10/2008",
"EventType": "Restricted",
"Event": "My Forum",
"SessionStartTime": "15:10",
"City": "London",
"Type": "3on1",
"RowCount": 1
},
{
"EventStartDate": "24/11/2008",
"EventType": "Conference",
"Event": "AAA Test Event",
"SessionStartTime": "15:10",
"City": "Paris",
"Type": "Meeting",
"RowCount": 2
},
{
"EventStartDate": "24/11/2008",
"EventType": "Conference",
"Event": "AAA Test Event",
"SessionStartTime": "16:10",
"City": "Moscow",
"Type": "Breakfast",
"RowCount": 3
}
]
Необходимо сгруппировать по датам, названиям, типам ивентов и их сессий.
и тд. Скрипт цикла перебора массива:
var arr2 = [];
for (var i = 0; i < arr1.length; i++) {
if (arr2[arr1[i].EventStartDate] && arr2[arr1[i].EventStartDate].EventStartDate) {
for (n in arr1[i]) {
if (n != 'EventStartDate') {
arr2[arr1[i].EventStartDate][n] = (arr2[arr1[i].EventStartDate][n]) ? arr2[arr1[i].EventStartDate][n] + ";" + arr1[i][n] : arr1[i][n];
}
}
} else {
arr2[arr1[i].EventStartDate] = arr1[i];
}
}
console.log('result', arr2);
Прошу помочь разобраться как переработать такой массив.
UPD: необходимый результат HTML
<div class="cib-day-elem">
<div class="cib-label-am">
<div type="text" class="event" name="dc_input0" id="dc_input0"><a class="cib-date">"EventStartDate(17/10/2008)"</a><br>
<div class="cib-event"><a class="typeevent">"EventType"</a><a class="nevent">▶"Event"</a><br>
<div class="cib-s1"><a class="tm">"SessionStartTime"</a><a>"City"</a><a class="type">"Type"</a></div>
<div class="cib-s2"><a class="tm">"SessionStartTime"</a><a>"City"</a><a class="type">"Type"</a></div>
<div class="cib-s3"><a class="tm">"SessionStartTime"</a><a>"City"</a><a class="type">"Type"</a></div>
</div>
</div>
</div>
</div>
<div class="cib-label-am">
<div type="text" class="event" name="dc_input2" id="dc_input2"><a class="cib-date">"EventStartDate(24/11/2008)"</a><br>
<div class="cib-event"><a class="typeevent">"EventType"</a><a class="nevent">▶"Event"</a><br>
<div class="cib-s1"><a class="tm">"SessionStartTime"</a><a>"City"</a><a class="type">"Type"</a></div>
<div class="cib-s2"><a class="tm">"SessionStartTime"</a><a>"City"</a><a class="type">"Type"</a> </div>
</div>
</div>
</div>
</div>