Я получаю этот json файл, в котором перечислены одна или несколько записей. Когда имеется несколько записей, записи помещаются в массив. В противном случае нет массива. Я пытаюсь извлечь ключ сеанса из записей с помощью jq. Есть ли общий c способ сопоставить оба случая:
Пример № 1: сообщение с несколькими записями:
{
"message": {
"header": {
"response": {
"result": "SUCCESS",
"gsbStatus": "PRIMARY"
}
},
"body": {
"bodyContent": {
"type": "history:lstmeetingusageHistoryResponse",
"meetingUsageHistory": [
{
"sessionKey": "1263859083",
"meetingUUID": "603f5595dc8e4c7a9c2esdfsdf494cfae91815",
"confName": "sdfsdf setup for Dsdfdf alerts",
"meetingStartTime": "07/09/2020 14:00:17",
"meetingEndTime": "07/09/2020 15:01:53",
"duration": "62",
"timezone": "GMT-05:00, Central (Chicago)",
"timeZoneID": "7",
"timeZoneWithDST": "Chicago (Central Daylight Time, GMT-05:00)",
"trackingCode": null,
"meetingType": "PRO",
"hostWebExID": "conferenceroom01@abc.com",
"hostName": "test Tech",
"hostEmail": "conferenceroom01@abc.com",
"totalCallInMinutes": "0",
"totalPeopleMinutes": "192",
"totalCallInTollfreeMinutes": "0",
"totalCallOutDomestic": "0",
"totalCallOutInternational": "0",
"totalCallOutInternal": "0",
"totalCallInInternational": "0",
"tollCallInInternational": "0",
"tollfreeCallInInternational": "0",
"totalVoipMinutes": "192",
"userID": "544798712",
"totalParticipants": "4",
"totalParticipantsVoip": "4",
"totalParticipantsCallIn": "0",
"totalParticipantsCallOut": "0",
"confID": "166058947180001507",
"peakAttendee": "4",
"assistService": null
},
{
"sessionKey": "623922696",
"meetingUUID": "503dsfsdfsdfd4280e4a452e03b9c75dce0f26",
"confName": "test Tech's Personal Room",
"meetingStartTime": "06/24/2020 19:21:57",
"meetingEndTime": "06/24/2020 20:11:42",
"duration": "50",
"timezone": "GMT-05:00, Central (Chicago)",
"timeZoneID": "7",
"timeZoneWithDST": "Chicago (Central Daylight Time, GMT-05:00)",
"trackingCode": null,
"meetingType": "PRO",
"hostWebExID": "conferenceroom01@abc.com",
"hostName": "test Tech",
"hostEmail": "conferenceroom01@abc.com",
"totalCallInMinutes": "0",
"totalPeopleMinutes": "100",
"totalCallInTollfreeMinutes": "0",
"totalCallOutDomestic": "0",
"totalCallOutInternational": "0",
"totalCallOutInternal": "0",
"totalCallInInternational": "0",
"tollCallInInternational": "0",
"tollfreeCallInInternational": "0",
"totalVoipMinutes": "100",
"userID": "544798712",
"totalParticipants": "2",
"totalParticipantsVoip": "2",
"totalParticipantsCallIn": "0",
"totalParticipantsCallOut": "0",
"confID": "164945117836245416",
"peakAttendee": "2",
"assistService": null
}
],
"matchingRecords": {
"total": "2",
"returned": "2",
"startFrom": "1"
}
}
}
}
}
Пример № 2: сообщение с одной записью:
{
"message": {
"header": {
"response": {
"result": "SUCCESS",
"gsbStatus": "PRIMARY"
}
},
"body": {
"bodyContent": {
"type": "history:lstmeetingusageHistoryResponse",
"meetingUsageHistory": {
"sessionKey": "297115075",
"meetingUUID": "sdsadfdsfsfsfdsfsdf",
"confName": "abc's Personal Room",
"meetingStartTime": "07/09/2020 20:58:37",
"meetingEndTime": "07/09/2020 22:38:15",
"duration": "100",
"timezone": "GMT-05:00, Central (Chicago)",
"timeZoneID": "7",
"timeZoneWithDST": "Chicago (Central Daylight Time, GMT-05:00)",
"trackingCode": null,
"meetingType": "PRO",
"hostWebExID": "asdsad@abc.com",
"hostName": "asdasdasdasd",
"hostEmail": "asdsad@abc.com",
"totalCallInMinutes": "0",
"totalPeopleMinutes": "197",
"totalCallInTollfreeMinutes": "0",
"totalCallOutDomestic": "0",
"totalCallOutInternational": "0",
"totalCallOutInternal": "0",
"totalCallInInternational": "0",
"tollCallInInternational": "0",
"tollfreeCallInInternational": "0",
"totalVoipMinutes": "197",
"userID": "487886288",
"totalParticipants": "3",
"totalParticipantsVoip": "3",
"totalParticipantsCallIn": "0",
"totalParticipantsCallOut": "0",
"confID": "166305919935739955",
"peakAttendee": "2",
"assistService": null
},
"matchingRecords": {
"total": "1",
"returned": "1",
"startFrom": "1"
}
}
}
}
}
Спасибо