I need help on parsing a complex JSON. I've spent a lot of time searching the web to find solutions but I get more confused as I search. I don't usually work with JSON so I'm pretty novice.
In the JSON below, if someone could show me some code that would get me to the
trainId field (about 10 lines from the bottom), I could probably figure out everything else from that since that would be one of the deepest levels of this JSON.
{
"properties" : {
"messageType" : "tripOrderRequest",
"sentDateTime" : "2017-08-10T11:40:01.454Z",
"senderId" : "1",
"recipientId" : "2",
"messageIntExt" : "external",
"eventTypeVersion" : "1.1"
},
"body" : {
"tripOrderId" : "d0b0f506-acbc-42f3-b712-bed7c60ff6b5",
"shortKey" : "0ff6b5",
"requestedVanHub" : "Oklahoma City, OK",
"requestedVanHubID" : "1beff5b5-2cd3-41d3-9e34-f45a10717045",
"tripOrderItinerary" : [ {
"sequence" : 1,
"type" : "P",
"status" : "P",
"associatedTripId" : "0bb3ab5d-9f08-488f-89f3-b07b072b6d51",
"locationId" : "d78888a4-a6da-4c8c-b2d8-fbdd4b332394",
"locationLat" : 36.116381,
"locationLong" : -96.010583
},{
"sequence" : 2,
"type" : "D",
"status" : "P",
"associatedTripId" : "0bb3ab5d-9f08-488f-89f3-b07b072b6d51",
"locationId" : "c7016a4f-da4b-41d0-9f93-b38af1c36827",
"locationLat" : 36.097914,
"locationLong" : -95.865680
} ],
"tripDetails" : [ {
"tripId" : "0bb3ab5d-9f08-488f-89f3-b07b072b6d51",
"shortKey" : "2b6d51",
"sequence" : 10,
"pickupLocation" : {
"adhoc" : {
"lat" : 36.116381,
"lng" : -96.010583
},
"knownLocation" : {
"lat" : 36.116381,
"lng" : -96.010583,
"locationId" : "d78888a4-a6da-4c8c-b2d8-fbdd4b332394",
"name" : "Tulsa OK",
"address" : "1631 W 33RD PL, Tulsa, Oklahoma, 74107",
"radioChannel" : 51
}
},
"dropOffLocation" : {
"adhoc" : {
"lat" : 36.097914,
"lng" : -95.865680
},
"knownLocation" : {
"lat" : 36.097914,
"lng" : -95.865680,
"locationId" : "c7016a4f-da4b-41d0-9f93-b38af1c36827",
"name" : "Tulsa - Cherokee YA OK",
"address" : "1631 W 33RD PL, Tulsa, Oklahoma, 74107",
"radioChannel" : 52
}
},
"pickupSchedule" : {
"preferredTimeZone" : "CDT",
"needDateTime" : "2017-09-10T11:40:01.454Z",
"pickupDateTime" : "2017-09-10T12:40:01.454Z"
},
"conveyance" : {
"crew" : {
"crewMember" : [ {
"sequence" : 1,
"name" : "John Doe",
"id" : "x8888"
},{
"sequence" : 2,
"name" : "Johnny Doe",
"id" : "x8885"
} ],
"associatedTrainDetails" : {
"trainId" : "HPASLVJ113A",
"leadLocomotiveId" : "BNSF 2347"
}
},
"equipments" : [],
"passenger" : []
}
} ]
}
}
What I have tried:
I have found ways to parse simple JSON using
Newtonsoft.Json but can't seem to adapt it to get to deeper levels. I'm running short on a deadline to get this done.