NiFi convert avro to JSON array format with nested array - json

New to Nifi and looking to see if we can convert results of SQL to JSON in the requested format.
SQL result is :
member_id
field2
total
tax
ship
partnum
price
qty
874450963
24017
173.95
0
0
015935966
42
1
874450963
24017
173.95
0
0
000756009
32
1
874450963
24017
173.95
0
0
012179293
99.95
1
The out of the box result looks like this using either ConvertRecord or ConvertAvroToJSON process:
[
{
"FIELD2": "24017",
"MEMBER_ID": "874450963",
"PARTNUM": "015935966",
"PRICE": "42",
"QUANTITY": "1",
"TIMEPLACED": null,
"TOTALPRODUCT": "173.95",
"TOTALSHIPPING": "0",
"TOTALTAX": "0"
},
{
"FIELD2": "24017",
"MEMBER_ID": "874450963",
"PARTNUM": "000756009",
"PRICE": "32",
"QUANTITY": "1",
"TIMEPLACED": null,
"TOTALPRODUCT": "173.95",
"TOTALSHIPPING": "0",
"TOTALTAX": "0"
},
{
"FIELD2": "24017",
"MEMBER_ID": "874450963",
"PARTNUM": "012179293",
"PRICE": "99.95",
"QUANTITY": "1",
"TIMEPLACED": null,
"TOTALPRODUCT": "173.95",
"TOTALSHIPPING": "0",
"TOTALTAX": "0"
}
]
Request is to group these and have the partnum, price and quantity as an array like this:
[
{
"FIELD2": "24017",
"MEMBER_ID": "874450963",
"TIMEPLACED": null,
"TOTALPRODUCT": "173.95",
"TOTALSHIPPING": "0",
"TOTALTAX": "0",
"itemDetails": [
{
"PARTNUM": "015935966",
"PRICE": "42",
"QUANTITY": "1"
},
{
"PARTNUM": "000756009",
"PRICE": "32",
"QUANTITY": "1"
},
{
"PARTNUM": "012179293",
"PRICE": "99.95",
"QUANTITY": "1"
}
]
}
]
How do we do this?
Thanks!
Searched forum and didn't see anything similar.
New Scenario:
[
{
"FIELD2": "24017",
"MEMBER_ID": "874450963",
"PARTNUM": "015935966",
"PRICE": "42",
"QUANTITY": "1",
"TIMEPLACED": null,
"TOTALPRODUCT": "173.95",
"TOTALSHIPPING": "0",
"TOTALTAX": "0"
},
{
"FIELD2": "24017",
"MEMBER_ID": "874450963",
"PARTNUM": "000756009",
"PRICE": "32",
"QUANTITY": "1",
"TIMEPLACED": null,
"TOTALPRODUCT": "173.95",
"TOTALSHIPPING": "0",
"TOTALTAX": "0"
},
{
"FIELD2": "24017",
"MEMBER_ID": "874450963",
"PARTNUM": "012179293",
"PRICE": "99.95",
"QUANTITY": "1",
"TIMEPLACED": null,
"TOTALPRODUCT": "173.95",
"TOTALSHIPPING": "0",
"TOTALTAX": "0"
},
{
"FIELD2": "25008",
"MEMBER_ID": "874221898",
"PARTNUM": "013519828",
"PRICE": "16.95",
"QUANTITY": "1",
"TIMEPLACED": null,
"TOTALPRODUCT": "83.80",
"TOTALSHIPPING": "0",
"TOTALTAX": "0"
},
{
"FIELD2": "25008",
"MEMBER_ID": "874221898",
"PARTNUM": "012625445",
"PRICE": "5.95",
"QUANTITY": "1",
"TIMEPLACED": null,
"TOTALPRODUCT": "83.80",
"TOTALSHIPPING": "0",
"TOTALTAX": "0"
},
{
"FIELD2": "25008",
"MEMBER_ID": "874221898",
"PARTNUM": "017219152",
"PRICE": "54.95",
"QUANTITY": "1",
"TIMEPLACED": null,
"TOTALPRODUCT": "83.80",
"TOTALSHIPPING": "0",
"TOTALTAX": "0"
}
]
Result should be:
[
{
"FIELD2": "24017",
"MEMBER_ID": "874450963",
"TIMEPLACED": null,
"TOTALPRODUCT": "173.95",
"TOTALSHIPPING": "0",
"TOTALTAX": "0",
"itemDetails": [
{
"PARTNUM": "015935966",
"PRICE": "42",
"QUANTITY": "1"
},
{
"PARTNUM": "000756009",
"PRICE": "32",
"QUANTITY": "1"
},
{
"PARTNUM": "012179293",
"PRICE": "99.95",
"QUANTITY": "1"
}
]
},
{
"FIELD2": "25008",
"MEMBER_ID": "874221898",
"TIMEPLACED": null,
"TOTALPRODUCT": "183.80",
"TOTALSHIPPING": "0",
"TOTALTAX": "0",
"itemDetails": [
{
"PARTNUM": "013519828",
"PRICE": "16.95",
"QUANTITY": "1"
},
{
"PARTNUM": "012625445",
"PRICE": "5.95",
"QUANTITY": "1"
},
{
"PARTNUM": "017219152",
"PRICE": "54.95",
"QUANTITY": "1"
}
]
}
]

One option would be carrying out this conversion by using JoltTransformJSON process with the following specification :
[
{
"operation": "shift",
"spec": {
"*": {
"*": "&", // form arrays for the attibutes with keys other than below ones
"PARTNUM|PRICE|QUANTITY": "itemDetails[&1].&"
}
}
},
{
"operation": "cardinality",
"spec": {
"*": "ONE", // pick only one of the repeating components
"itemDetails": "MANY"
}
},
{
"operation": "sort"
}
]
Edit : You can handle the new case through determining an attribute as a key id such as FIELD2 or MEMBER_ID( I picked FIELD2 ) such as
[
{
"operation": "shift",
"spec": {
"*": {
"*": "#1,FIELD2.&",
"PARTNUM|PRICE|QUANTITY": "#1,FIELD2.itemDetails[&1].&"
}
}
},
{ // get rid of object keys
"operation": "shift",
"spec": {
"*": ""
}
},
{
"operation": "cardinality",
"spec": {
"*": {
"*": "ONE", // pick only one of the repeating components
"itemDetails": "MANY"
}
}
},
{ // just to order the attributes
"operation": "sort"
},
{// get rid of redundantly generated null values
"operation": "modify-overwrite-beta",
"spec": {
"*": "=recursivelySquashNulls"
}
}
]

Related

Convert Flat JSON to Nested JSON with arrays

I am facing a problem, transforming flat JSON to the nested JSON using jolt transformation. And I am very new to jolt Transformation. Input and output detail is given below.
My input
[
{
"ProposalId": "1234",
"ReplStrategy": "External",
"CreatedDate": "2022-10-26",
"ValidFromDate": "2022-10-26",
"DeliveryDate": "2022-10-29",
"InventLocationIdFrom": "10",
"InventLocationIdTo": "12",
"RetailVariantId": "123457",
"Qty": 12
},
{
"ProposalId": "1234",
"ReplStrategy": "External",
"CreatedDate": "2022-10-26",
"ValidFromDate": "2022-10-26",
"DeliveryDate": "2022-10-29",
"InventLocationIdFrom": "10",
"InventLocationIdTo": "12",
"RetailVariantId": "123458",
"Qty": 16
},
{
"ProposalId": "1235",
"ReplStrategy": "External",
"CreatedDate": "2022-10-26",
"ValidFromDate": "2022-10-26",
"DeliveryDate": "2022-10-29",
"InventLocationIdFrom": "10",
"InventLocationIdTo": "12",
"RetailVariantId": "123459",
"Qty": 12
},
{
"ProposalId": "1235",
"ReplStrategy": "External",
"CreatedDate": "2022-10-26",
"ValidFromDate": "2022-10-26",
"DeliveryDate": "2022-10-29",
"InventLocationIdFrom": "10",
"InventLocationIdTo": "12",
"RetailVariantId": "123460",
"Qty": 16
},
{
"ProposalId": "1235",
"ReplStrategy": "External",
"CreatedDate": "2022-10-26",
"ValidFromDate": "2022-10-26",
"DeliveryDate": "2022-10-29",
"InventLocationIdFrom": "10",
"InventLocationIdTo": "12",
"RetailVariantId": "123461",
"Qty": 16
}
]
expected output
{
"Proposal": [
{
"ProposalId": "1234",
"ReplStrategy": "External",
"CreatedDate": "2022-10-26",
"ValidFromDate": "2022-10-26",
"DeliveryDate": "2022-10-29",
"InventLocationIdFrom": "10",
"InventLocationIdTo": "12",
"RetailVariant": [
{
"RetailVariantId": "123456",
"Qty": 15,
},
{
"RetailVariantId": "123457",
"Qty": 12,
}
]
},
{
"ProposalId": "1235",
"ReplStrategy": "TwoPhased",
"CreatedDate": "2022-10-26",
"ValidFromDate": "2022-10-26",
"DeliveryDate": "2022-10-29",
"InventLocationIdFrom": "10",
"InventLocationIdTo": "12",
"RetailVariant": [
{
"RetailVariantId": "123458",
"Qty": 13,
},
{
"RetailVariantId": "123459",
"Qty": 11,
}
]
}
]
}
I wrote jolt spec and I'm not getting the desired output
Jolt i used
[
{
"operation": "shift",
"spec": {
"*": {
"ProposalId": "#(1,ProposalId).Proposal.&",
"ReplStrategy": "#(1,ProposalId).Proposal.&",
"CreatedDate": "#(1,ProposalId).Proposal.&",
"ValidFromDate": "#(1,ProposalId).Proposal.&",
"DeliveryDate": "#(1,ProposalId).Proposal.&",
"InventLocationIdFrom": "#(1,ProposalId).Proposal.&",
"InventLocationIdTo": "#(1,ProposalId).Proposal.&",
"*": "#(1,ProposalId).Proposal.RetailVariant[&1].&"
}
}
},
{
"operation": "modify-overwrite-beta",
"spec": {
"*": "=recursivelySquashNulls"
}
},
{
"operation": "cardinality",
"spec": {
"*": {
"*": {
"ProposalId": "ONE",
"ReplStrategy": "ONE",
"CreatedDate": "ONE",
"ValidFromDate": "ONE",
"DeliveryDate": "ONE",
"InventLocationIdFrom": "ONE",
"InventLocationIdTo": "ONE"
}
}
}
},
{
"operation": "shift",
"spec": {
"*": ""
}
}
]
Can anyone who is a jolt expert, help me get the desired output. I think i m stuck in the last step
You can use
[
{ // group by ProposalId values
"operation": "shift",
"spec": {
"*": {
"*": "#(1,ProposalId).&",
"RetailVariantId|Qty": {
"#": "#(2,ProposalId).RetailVariant[&2].&"
}
}
}
},
{ // nest all JSON value within Proposal array
"operation": "shift",
"spec": {
"*": "Proposal[]"
}
},
{
"operation": "cardinality",
"spec": {
"*": {
"*": {
"*": "ONE",
"RetailVariant": "MANY"
}
}
}
},
{ // get rid of redundant nulls
"operation": "modify-overwrite-beta",
"spec": {
"*": "=recursivelySquashNulls"
}
}
]
the demo on the site http://jolt-demo.appspot.com/ is

find on id and append value to json parameter

I have the following data frame, df1:
A B C
123 B1 C1
456 B2 C2
And data frame df2:
A
[
{
"id": "123",
"details": {
"id": "123",
"color": null,
"param_1": {
"name": "mike"
},
"location": "US",
"items": [
{
"item_1": "#227858",
"offer_id": null,
"item_details": {
"detials_1": [{ "notes": "other:", "quantity": 1 }]
}
}
],
"version": 1,
}
}
]
[
{
"id": "456",
"details": {
"id": "456",
"color": null,
"param_1": {
"name": "james"
},
"location": "KR",
"items": [
{
"item_1": "#2221",
"offer_id": null,
"item_details": {
"detials_1": [{ "notes": "other", "quantity": 1 }]
}
}
],
"version": 2,
}
}
]
I want to find all values in df1[A] inside the JSON found inside df2[A] under the first instance of the id parameter. Once found, I want to replace the NULL values inside the color parameter with the df1[B] and offer_id with df1[C].
The output should create a new column with the appended values:
df2[B]:
[
{
"id": "123",
"details": {
"id": "123",
"color": B1,
"param_1": {
"name": "mike"
},
"location": "US",
"items": [
{
"item_1": "#227858",
"offer_id": C1,
"item_details": {
"detials_1": [{ "notes": "other:", "quantity": 1 }]
}
}
],
"version": 1,
}
}
]
[
{
"id": "456",
"details": {
"id": "456",
"color": B2,
"param_1": {
"name": "james"
},
"location": "KR",
"items": [
{
"item_1": "#2221",
"offer_id": C2,
"item_details": {
"detials_1": [{ "notes": "other", "quantity": 1 }]
}
}
],
"version": 2,
}
}
]
I just started researching how to approach this, but I need guidance on the most efficient way. Any insight would be greatly appreciated.

Jolt spec is working for most cases but not for some nested array

My jolt spec is working for most of the scenarios, but when there is different elements in the nested arrays, we are getting one Extra null. Can we correct that
I am new to nifi. I was trying to create a jolt spec but not getting it. Could anyone please help me. Details as below: The Attributes in flow file
[
{
"PC9Code": "678990-0000",
"ProductDescription": "94520 STANDARD SHORT STEEL BLACK ADV SHO",
"MaterialType": "Finished Goods",
"ProductType": "REGULAR",
"Brand": "LEVIS",
"ProductCategory": "BOTTOMS",
"ConsumerGroup": "MEN",
"Gender": "MALE",
"CapsuleName": "0",
"FFCCode": "X3209",
"FFCName": "STEEL BLACK ADV SHORT",
"StyleCode": "94520",
"StyleName": "94520 STANDARD SHORT",
"ProductLine": "Levi's Mainline",
"ProductSubCategory": "SHORTS",
"ProductClass": "SHORTS",
"ProductSubClass": "MID LENGTH SHORTS",
"CarryOver": "N",
"ProductPricePositioningDesc": "TIER 3",
"AgilityIndicator": "N",
"OriginalBFF": "0",
"ProductLifeCycle": "SEASONAL",
"ColorCode": "X3209",
"ColorName": "STEEL BLACK ADV SHOR",
"EarlyDelivery": "NO",
"FirstOnFloorMonth": "1",
"GlobalPlanningView": "0",
"UOM": "EA",
"PC13": [
{
"SKU": "00501000030399999210",
"DIM1": "3078",
"DIM2": "3079"
}
],
"OperationType": "UPDATE",
"TimeStamp": "6/2/2022 4:52:17 PM"
},
{
"PC9Code": "12385-0000",
"ProductDescription": "94520 STANDARD SHORT STEEL BLACK ADV SHO",
"MaterialType": "Finished Goods",
"ProductType": "REGULAR",
"Brand": "LEVIS",
"ProductCategory": "BOTTOMS",
"ConsumerGroup": "MEN",
"Gender": "MALE",
"CapsuleName": "0",
"FFCCode": "X3209",
"FFCName": "STEEL BLACK ADV SHORT",
"StyleCode": "94520",
"StyleName": "94520 STANDARD SHORT",
"ProductLine": "Levi's Mainline",
"ProductSubCategory": "SHORTS",
"ProductClass": "SHORTS",
"ProductSubClass": "MID LENGTH SHORTS",
"CarryOver": "N",
"ProductPricePositioningDesc": "TIER 3",
"AgilityIndicator": "N",
"OriginalBFF": "0",
"ProductLifeCycle": "SEASONAL",
"ColorCode": "X3209",
"ColorName": "STEEL BLACK ADV SHOR",
"EarlyDelivery": "NO",
"FirstOnFloorMonth": "1",
"GlobalPlanningView": "0",
"UOM": "EA",
"PC13": [
{
"SKU": "0050100003030",
"DIM1": "30",
"DIM2": "30"
},
{
"SKU": "00501000030301221",
"DIM1": "310",
"DIM2": "3023"
}
],
"OperationType": "UPDATE",
"TimeStamp": "6/2/2022 4:52:17 PM"
}
]
Current Jolt Spec
[
{
"operation": "shift",
"spec": {
"*": {
"PC13": {
"*": {
"#": "&[&3]",
"#(2,AgilityIndicator)": "&[&3].AgilityIndicator",
"#(2,Brand)": "&[&3].Brand",
"#(2,CapsuleName)": "&[&3].CapsuleName",
"#(2,CarryOver)": "&[&3].CarryOver",
"#(2,ColorCode)": "&[&3].ColorCode",
"#(2,ColorName)": "&[&3].ColorName",
"#(2,ConsumerGroup)": "&[&3].ConsumerGroup",
"#(2,EarlyDelivery)": "&[&3].EarlyDelivery",
"#(2,FFCCode)": "&[&3].FFCCode",
"#(2,FFCName)": "&[&3].FFCName",
"#(2,FirstOnFloorMonth)": "&[&3].FirstOnFloorMonth",
"#(2,Gender)": "&[&3].Gender",
"#(2,GlobalPlanningView)": "&[&3].GlobalPlanningView",
"#(2,MaterialType)": "&[&3].MaterialType",
"#(2,OperationType)": "&[&3].OperationType",
"#(2,OriginalBFF)": "&[&3].OriginalBFF",
"#(2,PC9Code)": "&[&3].PC9Code",
"#(2,ProductCategory)": "&[&3].ProductCategory",
"#(2,ProductClass)": "&[&3].ProductClass",
"#(2,ProductDescription)": "&[&3].ProductDescription",
"#(2,ProductLifeCycle)": "&[&3].ProductLifeCycle",
"#(2,ProductLine)": "&[&3].ProductLine",
"#(2,ProductPricePositioningDesc)": "&[&3].ProductPricePositioningDesc",
"#(2,ProductSubCategory)": "&[&3].ProductSubCategory",
"#(2,ProductSubClass)": "&[&3].ProductSubClass",
"#(2,ProductType)": "&[&3].ProductType",
"#(2,StyleCode)": "&[&3].StyleCode",
"#(2,StyleName)": "&[&3].StyleName",
"#(2,TimeStamp)": "&[&3].TimeStamp",
"#(2,UOM)": "&[&3].UOM"
}
}
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"*": "&1.&"
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"*": ""
}
}
}
]
The Image Of Current Output
Having one null inbetween the elements
You can add two more transformations to the current spec such as
[
<the current spec>,
{
"operation": "shift",
"spec": {
"*": {
"*": {
"*": "&2.&1.&" // separate each object levels
}
}
}
},
{
"operation": "shift",
"spec": {
"*": {
"*": ""
}
}
}
]
in which occuring one level deeper shift removes the non-objects

Selectively get certain arrays from inside an array in JSON using JOLT

I've been trying to get some fields out of a very long and complicated json format but not getting the output I want.
MY current spec obtains all events from the event array and lists them in the output. I'm unsure how to select specific events and only output those. Am not quite sure of the syntax
My JSON:
{
"rootid": "19718",
"clloadm": "2021-06-01T22:40:02",
"clload": "2021-06-01T21:21:39",
"date": "2021-05-25T21:52:30",
"events": [
{
"done": {
"id": "e0",
"value": "2021-05-29T08:08:19"
},
"id": "e0_event",
"started": {
"id": "e0",
"value": "2021-05-29T08:08:19"
},
"status": "complete"
},
{
"done": {
"id": "e1",
"value": "2021-05-27T02:20:25"
},
"id": "e1_event",
"started": {
"id": "e1",
"value": "2021-05-27T02:20:25"
},
"status": "complete"
},
{
"done": {
"id": "e2",
"value": "2021-05-29T08:08:19"
},
"id": "e2_event",
"started": {
"id": "e2",
"value": "2021-05-29T08:08:19"
},
"status": "complete"
},
{
"done": {
"id": "e3",
"value": "2021-05-29T08:08:19"
},
"id": "e3_event",
"started": {
"id": "e3",
"value": "2021-05-29T08:08:19"
},
"status": "complete"
},
{
"done": {
"id": "e4",
"value": "2021-05-29T08:08:19"
},
"id": "e4_event",
"started": {
"id": "e4",
"value": "2021-05-29T08:08:19"
},
"status": "complete"
}
],
"ids": [
{
"id": "id",
"source": "source",
"value": "value"
},
{
"id": "new_id",
"source": "new_source",
"value": "value"
}
]
}
My Jolt Spec that gets all events for now:
[
{
"operation": "shift",
"spec": {
"rootid": "rootid",
"clloadm": "clloadm",
"clload": "clload",
"date": "date",
"events": {
"*": {
"*": {
"#value": "#id"
}
}
},
"ids": {
"*": {
"#value": "#id"
}
}
}
}
]
The output I get:
{
"rootid" : "19718",
"clloadm" : "2021-06-01T22:40:02",
"clload" : "2021-06-01T21:21:39",
"date" : "2021-05-25T21:52:30",
"e0" : [ "2021-05-29T08:08:19", "2021-05-29T08:08:19" ],
"e1" : [ "2021-05-27T02:20:25", "2021-05-27T02:20:25" ],
"e2" : [ "2021-05-29T08:08:19", "2021-05-29T08:08:19" ],
"e3" : [ "2021-05-29T08:08:19", "2021-05-29T08:08:19" ],
"e4" : [ "2021-05-29T08:08:19", "2021-05-29T08:08:19" ],
"id" : "value",
"new_id" : "value"
}
The output I would like
{
"rootid" : "19718",
"clloadm" : "2021-06-01T22:40:02",
"clload" : "2021-06-01T21:21:39",
"date" : "2021-05-25T21:52:30",
"e0" : [ "2021-05-29T08:08:19", "2021-05-29T08:08:19" ],
"e4" : [ "2021-05-29T08:08:19", "2021-05-29T08:08:19" ],
"id" : "value",
"new_id" : "value"
}
You can write the individual keys e0 and e4 as conditional cases for #id key while rewriting the rest of the key-value pairs through "*":"&" representation such as
[
{
"operation": "shift",
"spec": {
"*": "&",
"events": {
"*": {
"*": {
"#id": {
"e0": { "#(2,value)": "&" },
"e4": { "#(2,value)": "&" }
}
}
}
},
"ids": {
"*": {
"#value": "#id"
}
}
}
}
]

Handling the optional arrays with jq

I am receiving this json file that lists one or more records. When there are multiple records, records are placed in an array. Otherwise, there is no array. I am trying to extract the sessionkey from the records using jq. Is there a generic way to match both cases:
Sample #1: message with multiple records:
{
"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"
}
}
}
}
}
Sample #2: message with a single record:
{
"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"
}
}
}
}
}
Thanks
If it is acceptable to print all "sessionKey" values, then the simplest would probably be:
.. | objects | select(has("sessionKey")) | .sessionKey
Otherwise you could use an if ... then ... else ... end approach.