I want to extract the values from "scanEvents" list or array. Each scanEvent has a date, eventtype, eventdescrption, derivedstatus, etc...
I have used several methods, such as this one below, but so far I am unable to extract the values for each "scanEvent"
var data = (JObject)JsonConvert.DeserializeObject(strFedExJSON);
var scanevents = data["scanEvents"];
var output = scanevents.Children<JProperty>()
.Select(prop => prop.Value.ToObject<Scanevent>())
.ToList();
foreach (var x in output)
{
richTextBox1.Text += output + Environment.NewLine;
}
I want to end up with this kind of output below:
"date": "2021-12-22T15:14:00-10:00", "eventDescription": "Delivered", "city": "HILO", "stateOrProvinceCode": "HI", "countryCode": "US", "locationType": "DELIVERY_LOCATION", "derivedStatus": "Delivered"
"date": "2021-12-22T14:40:00-10:00", "eventDescription": "On FedEx vehicle for delivery", "city": "HILO","stateOrProvinceCode": "HI","countryCode": "US", "locationType": "VEHICLE", "derivedStatus": "In transit"
"date": "2021-12-22T14:37:00-10:00","eventDescription": "At local FedEx facility","city": "countryCode": "US","HILO", "locationType": "DESTINATION_FEDEX_FACILITY", "derivedStatus": "In transit"
How do you extract the values (date, eventDescription, derivedstatus) for each event in "scanEvents" list below? This one seems to be buried under several types or objects.
{
"transactionId": "44d2c2a9-1204-4ff7-94f3-ae8699257f77",
"output": {
"completeTrackResults": [
{
"trackingNumber": "673247499414",
"trackResults": [
{
"trackingNumberInfo": {
"trackingNumber": "673247499414",
"trackingNumberUniqueId": "2459570000~673247499414~FX",
"carrierCode": "FDXE"
},
"additionalTrackingInfo": {
"nickname": "",
"packageIdentifiers": [
{
"type": "DEPARTMENT",
"values": [
"32 MQ"
],
"trackingNumberUniqueId": "",
"carrierCode": ""
},
{
"type": "SHIPPER_REFERENCE",
"values": [
"6033245/O956871"
],
"trackingNumberUniqueId": "",
"carrierCode": ""
}
],
"hasAssociatedShipments": false
},
"shipperInformation": {
"contact": {},
"address": {
"city": "MIRA LOMA",
"stateOrProvinceCode": "CA",
"countryCode": "US",
"residential": false,
"countryName": "United States"
}
},
"recipientInformation": {
"contact": {},
"address": {
"city": "HILO",
"stateOrProvinceCode": "HI",
"countryCode": "US",
"residential": false,
"countryName": "United States"
}
},
"latestStatusDetail": {
"code": "DL",
"derivedCode": "DL",
"statusByLocale": "Delivered",
"description": "Delivered",
"scanLocation": {
"city": "HILO",
"stateOrProvinceCode": "HI",
"countryCode": "US",
"residential": false,
"countryName": "United States"
}
},
"dateAndTimes": [
{
"type": "ACTUAL_DELIVERY",
"dateTime": "2021-12-22T15:14:00-10:00"
},
{
"type": "ACTUAL_PICKUP",
"dateTime": "2021-12-21T18:12:00-08:00"
},
{
"type": "SHIP",
"dateTime": "2021-12-21T00:00:00-06:00"
},
{
"type": "ACTUAL_TENDER",
"dateTime": "2021-12-21T18:14:00-08:00"
}
],
"availableImages": [
{
"type": "SIGNATURE_PROOF_OF_DELIVERY"
}
],
"specialHandlings": [
{
"type": "DELIVER_WEEKDAY",
"description": "Deliver Weekday",
"paymentType": "OTHER"
}
],
"packageDetails": {
"packagingDescription": {
"type": "YOUR_PACKAGING",
"description": "Your Packaging"
},
"sequenceNumber": "1",
"count": "1",
"weightAndDimensions": {
"weight": [
{
"value": "10.0",
"unit": "LB"
},
{
"value": "4.54",
"unit": "KG"
}
],
"dimensions": [
{
"length": 20,
"width": 12,
"height": 13,
"units": "IN"
},
{
"length": 50,
"width": 30,
"height": 33,
"units": "CM"
}
]
},
"packageContent": []
},
"shipmentDetails": {
"possessionStatus": true,
"weight": [
{
"value": "10.0",
"unit": "LB"
},
{
"value": "4.54",
"unit": "KG"
}
]
},
"scanEvents": [
{
"date": "2021-12-22T15:14:00-10:00",
"eventType": "DL",
"eventDescription": "Delivered",
"exceptionCode": "",
"exceptionDescription": "",
"scanLocation": {
"streetLines": [
""
],
"city": "HILO",
"stateOrProvinceCode": "HI",
"postalCode": "96720",
"countryCode": "US",
"residential": false,
"countryName": "United States"
},
"locationId": "ITOA",
"locationType": "DELIVERY_LOCATION",
"derivedStatusCode": "DL",
"derivedStatus": "Delivered"
},
{
"date": "2021-12-22T14:40:00-10:00",
"eventType": "OD",
"eventDescription": "On FedEx vehicle for delivery",
"exceptionCode": "",
"exceptionDescription": "",
"scanLocation": {
"streetLines": [
""
],
"city": "HILO",
"stateOrProvinceCode": "HI",
"postalCode": "96720",
"countryCode": "US",
"residential": false,
"countryName": "United States"
},
"locationId": "ITOA",
"locationType": "VEHICLE",
"derivedStatusCode": "IT",
"derivedStatus": "In transit"
},
{
"date": "2021-12-22T14:37:00-10:00",
"eventType": "AR",
"eventDescription": "At local FedEx facility",
"exceptionCode": "",
"exceptionDescription": "",
"scanLocation": {
"streetLines": [
""
],
"city": "HILO",
"stateOrProvinceCode": "HI",
"postalCode": "96720",
"countryCode": "US",
"residential": false,
"countryName": "United States"
},
"locationId": "ITOA",
"locationType": "DESTINATION_FEDEX_FACILITY",
"derivedStatusCode": "IT",
"derivedStatus": "In transit"
},
{
"date": "2021-12-22T07:35:00-10:00",
"eventType": "AR",
"eventDescription": "At destination sort facility",
"exceptionCode": "",
"exceptionDescription": "",
"scanLocation": {
"streetLines": [
""
],
"city": "HONOLULU",
"stateOrProvinceCode": "HI",
"postalCode": "96819",
"countryCode": "US",
"residential": false,
"countryName": "United States"
},
"locationId": "HNLR",
"locationType": "SORT_FACILITY",
"derivedStatusCode": "IT",
"derivedStatus": "In transit"
},
{
"date": "2021-12-22T04:21:00-08:00",
"eventType": "DP",
"eventDescription": "Departed FedEx hub",
"exceptionCode": "",
"exceptionDescription": "",
"scanLocation": {
"streetLines": [
""
],
"city": "OAKLAND",
"stateOrProvinceCode": "CA",
"postalCode": "94621",
"countryCode": "US",
"residential": false,
"countryName": "United States"
},
"locationId": "OAKH",
"locationType": "FEDEX_FACILITY",
"derivedStatusCode": "IT",
"derivedStatus": "In transit"
},
{
"date": "2021-12-21T23:27:00-08:00",
"eventType": "AR",
"eventDescription": "Arrived at FedEx hub",
"exceptionCode": "",
"exceptionDescription": "",
"scanLocation": {
"streetLines": [
""
],
"city": "OAKLAND",
"stateOrProvinceCode": "CA",
"postalCode": "94621",
"countryCode": "US",
"residential": false,
"countryName": "United States"
},
"locationId": "OAKH",
"locationType": "FEDEX_FACILITY",
"derivedStatusCode": "IT",
"derivedStatus": "In transit"
},
{
"date": "2021-12-21T19:13:00-08:00",
"eventType": "DP",
"eventDescription": "Left FedEx origin facility",
"exceptionCode": "",
"exceptionDescription": "",
"scanLocation": {
"streetLines": [
""
],
"city": "ONTARIO",
"stateOrProvinceCode": "CA",
"postalCode": "91761",
"countryCode": "US",
"residential": false,
"countryName": "United States"
},
"locationId": "ONTA",
"locationType": "ORIGIN_FEDEX_FACILITY",
"derivedStatusCode": "IT",
"derivedStatus": "In transit"
},
{
"date": "2021-12-21T18:12:00-08:00",
"eventType": "PU",
"eventDescription": "Picked up",
"exceptionCode": "",
"exceptionDescription": "",
"scanLocation": {
"streetLines": [
""
],
"city": "ONTARIO",
"stateOrProvinceCode": "CA",
"postalCode": "91761",
"countryCode": "US",
"residential": false,
"countryName": "United States"
},
"locationId": "ONTA",
"locationType": "PICKUP_LOCATION",
"derivedStatusCode": "PU",
"derivedStatus": "Picked up"
},
{
"date": "2021-12-21T16:55:06-06:00",
"eventType": "OC",
"eventDescription": "Shipment information sent to FedEx",
"exceptionCode": "",
"exceptionDescription": "",
"scanLocation": {
"streetLines": [
""
],
"residential": false
},
"locationType": "CUSTOMER",
"derivedStatusCode": "IN",
"derivedStatus": "Initiated"
}
],
"availableNotifications": [
"ON_DELIVERY"
],
"deliveryDetails": {
"actualDeliveryAddress": {
"city": "HILO",
"stateOrProvinceCode": "HI",
"countryCode": "US",
"residential": false,
"countryName": "United States"
},
"locationType": "SHIPPING_RECEIVING",
"locationDescription": "Shipping/Receiving",
"deliveryAttempts": "0",
"receivedByName": "L.WEAVER",
"deliveryOptionEligibilityDetails": [
{
"option": "INDIRECT_SIGNATURE_RELEASE",
"eligibility": "INELIGIBLE"
},
{
"option": "REDIRECT_TO_HOLD_AT_LOCATION",
"eligibility": "INELIGIBLE"
},
{
"option": "REROUTE",
"eligibility": "INELIGIBLE"
},
{
"option": "RESCHEDULE",
"eligibility": "INELIGIBLE"
},
{
"option": "RETURN_TO_SHIPPER",
"eligibility": "INELIGIBLE"
},
{
"option": "DISPUTE_DELIVERY",
"eligibility": "INELIGIBLE"
},
{
"option": "SUPPLEMENT_ADDRESS",
"eligibility": "INELIGIBLE"
}
]
},
"originLocation": {
"locationContactAndAddress": {
"address": {
"city": "ONTARIO",
"stateOrProvinceCode": "CA",
"countryCode": "US",
"residential": false,
"countryName": "United States"
}
},
"locationId": "ONTA"
},
"destinationLocation": {
"locationContactAndAddress": {
"address": {
"city": "HILO",
"stateOrProvinceCode": "HI",
"countryCode": "US",
"residential": false,
"countryName": "United States"
}
},
"locationType": ""
},
"lastUpdatedDestinationAddress": {
"city": "HILO",
"stateOrProvinceCode": "HI",
"countryCode": "US",
"residential": false,
"countryName": "United States"
},
"serviceDetail": {
"type": "PRIORITY_OVERNIGHT",
"description": "FedEx Priority Overnight",
"shortDescription": "PO"
},
"standardTransitTimeWindow": {
"window": {
"ends": "2021-12-22T17:00:00-10:00"
}
},
"estimatedDeliveryTimeWindow": {
"window": {}
},
"goodsClassificationCode": "",
"returnDetail": {}
}
]
}
]
}
}