If you only want to strip out the
WayBill
Numbers, then you can use:
Querying JSON with SelectToken - NewtownSoft[
^]
using Newtonsoft.Json.Linq;
string rawJson =
$$"""
{
"Status": true,
"Message": "Shipment Creation Successful",
"ResponseData": [{
"PickupBranchCode": "DKPG",
"DeliveryRouteCode": "HAKHG2M3",
"WayBill": ["ZND167281208805"],
"DeliveryHubCode": "HAKH",
"DeliveryBranchCode": "HAKH",
"PickupRouteCode": "DUSJW2WE",
"PickupHubCode": "HSHM"
}],
"Reason": null
}
""";
JObject jObj = JObject.Parse(rawJson);
IEnumerable<string> billNumbers = jObj
.SelectToken("$.ResponseData[0]['WayBill']")
.Values<string>();
string wayBillNumber = string.Join(", ", billNumbers);
Console.WriteLine($"WaBill #: {wayBillNumber}");
But if you want to deserialize the whole Json, then look at this article:
Working with Newtonsoft.Json in C# & VB[
^]