CSharp · Console
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json;
public class Program
{
public static void Main()
{
string content = @"{
""d"": {
""success"": true,
""errorMessage"": null,
""data"": {
""Orders"": [
{
""OrderID"": 4914194,
""FacilityID"": 1398,
""FacilityOrderID"": """",
""StatusID"": ""F"",
""Contract"": true,
""PermPlacement"": false,
""ShiftDate"": ""08/05/2019"",
""StartTime"": ""08:00:00"",
""EndTime"": ""17:00:00"",
""Meals"": 30,
""Con_StartDate"": ""08/05/2019"",
""Con_EndDate"": ""02/01/2020"",
""Locked"": true,
""LastModified"": ""2020-01-04 17:11:45"",
""CreatedDate"": ""2019-06-17 13:39:00"",
""FacilityName"": ""Carilion Roanoke Memorial Hospital"",
""ScheduledRegID"": 0,
""ScheduledRegName"": """",
""ClassName"": ""RAD3"",
""ClassDesc"": ""Rad Tech Specialty 2"",
""AltClassName"": """",
""AltClassDesc"": """",
""CodeName"": ""1"",
""ShiftNumber"": 1,
""AreaID"": 30799,
""AreaName"": ""Cardiology Clinic Outpatient"",
""AreaAddress1"": """",
""AreaAddress2"": """",
""AreaCity"": """",
""AreaCounty"": """",
""AreaState"": """",
""AreaZip"": """",
""LockReason"": ""Position is filled, awaiting credentials"",
""CancelReason"": """",
""Note"": ""Registered Echo Sonographer. 8 or 9 hours per day, 40 hours per week. Vascular experience helpful."",
""IsTraveler"": false,
""Rate"": 0,
""ContractPattern"": ""Sun, Mon, Tue, Wed, Thu, Fri, Sat"",
""Con_Guarantee"": 0,
""Con_Weeks"": 26
}
]
}
}
}";
var obj = JsonConvert.DeserializeObject<RootObject>(content);
var allOrders = obj.d.data.Orders;
Console.WriteLine(allOrders.Count());
Console.WriteLine(allOrders.FirstOrDefault().OrderID);
}
public class Order
{
public int OrderID { get; set; }
public int FacilityID { get; set; }
public string FacilityOrderID { get; set; }
public string StatusID { get; set; }
public bool Contract { get; set; }
public bool PermPlacement { get; set; }
public string ShiftDate { get; set; }
public string StartTime { get; set; }
public string EndTime { get; set; }
public int Meals { get; set; }
public string Con_StartDate { get; set; }
public string Con_EndDate { get; set; }
public bool Locked { get; set; }
public string LastModified { get; set; }
public string CreatedDate { get; set; }
public string FacilityName { get; set; }
public int ScheduledRegID { get; set; }
public string ScheduledRegName { get; set; }
public string ClassName { get; set; }
public string ClassDesc { get; set; }
public string AltClassName { get; set; }
public string AltClassDesc { get; set; }
public string CodeName { get; set; }
public int ShiftNumber { get; set; }
public int AreaID { get; set; }
public string AreaName { get; set; }
public string AreaAddress1 { get; set; }
public string AreaAddress2 { get; set; }
public string AreaCity { get; set; }
public string AreaCounty { get; set; }
public string AreaState { get; set; }
public string AreaZip { get; set; }
public string LockReason { get; set; }
public string CancelReason { get; set; }
public string Note { get; set; }
public bool IsTraveler { get; set; }
public int Rate { get; set; }
public string ContractPattern { get; set; }
public int Con_Guarantee { get; set; }
public int Con_Weeks { get; set; }
}
public class Data
{
public List<Order> Orders { get; set; }
}
public class D
{
public bool success { get; set; }
public object errorMessage { get; set; }
public Data data { get; set; }
}
public class RootObject
{
public D d { get; set; }
}
}