I have the following Json and I have converted to classes
Json :
{
"schedule": {
"afterStartMinutesBase": 0,
"beforeStartMinutesBase": 0,
"scheduleType": 2,
"id": "00000000-0000-0000-0000-000000000000",
"currentSchedule": {
"internalType": 2,
"daysOfWeek": [
0,
4,
5,
3
],
"weeksInterval": 1,
"daysOfWeekSource": [{
"name": "Sunday",
"value": 0,
"isSelectedInternal": true
},
{
"name": "Monday",
"value": 1,
"isSelectedInternal": false
},
{
"name": "Tuesday",
"value": 2,
"isSelectedInternal": false
},
{
"name": "Wednesday",
"value": 3,
"isSelectedInternal": true
},
{
"name": "Thursday",
"value": 4,
"isSelectedInternal": true
},
{
"name": "Friday",
"value": 5,
"isSelectedInternal": true
},
{
"name": "Saturday",
"value": 6,
"isSelectedInternal": false
}
],
"weeksIntervalOptions": {
"min": 1,
"max": 999,
"decimals": 0,
"format": "###,###"
}
},
"startBoundary": "2020-02-04T00:00:00-05:00",
"scheduleByWeek": {
"internalType": 2,
"daysOfWeek": [
0,
4,
5,
3
],
"weeksInterval": 1,
"daysOfWeekSource": [{
"name": "Sunday",
"value": 0,
"isSelectedInternal": true
},
{
"name": "Monday",
"value": 1,
"isSelectedInternal": false
},
{
"name": "Tuesday",
"value": 2,
"isSelectedInternal": false
},
{
"name": "Wednesday",
"value": 3,
"isSelectedInternal": true
},
{
"name": "Thursday",
"value": 4,
"isSelectedInternal": true
},
{
"name": "Friday",
"value": 5,
"isSelectedInternal": true
},
{
"name": "Saturday",
"value": 6,
"isSelectedInternal": false
}
],
"weeksIntervalOptions": {
"min": 1,
"max": 999,
"decimals": 0,
"format": "###,###"
}
},
"maxRunTime": "2:0:0",
"repetition": null,
"type": 32768
},
"taskOptions": {
"internalType": 0,
"information": "Data Clean up Auto"
},
"ignoreErrors": false
}
Here is my main model class that has the member properties:
I am having trouble setting the values of List<daysofweeksource> and List<daysofweeksource2>
public class Model
{
public static AdminServiceTaskModel CreateServiceTaskModel()
{
return new AdminServiceTaskModel()
{
schedule = new AdminServiceTaskModel.Schedule
{
afterStartMinutesBase = 0,
beforeStartMinutesBase = 0,
scheduleType = 2,
id = "00000000-0000-0000-0000-000000000000",
currentSchedule =
{
internalType = 2,
daysOfWeek = new List<int> { 0, 4, 5, 3 },
weeksInterval = 1,
daysOfWeekSource = new List<DaysOfWeekSource>
{
},
weeksIntervalOptions =
{
min = 1,
max = 999,
decimals = 0,
format = "###,###"
}
},
startBoundary = new DateTime(2020, 3, 31, 0, 0, 0, DateTimeKind.Local),
scheduleByWeek =
{
internalType = 2,
daysOfWeek = new List<int> { 0,4,5,3},
weeksInterval = 1,
daysOfWeekSource = new List<DaysOfWeekSource2>
{
},
weeksIntervalOptions =
{
min = 1,
max = 999,
decimals = 0,
format = "###,###"
}
},
maxRunTime = "2:0:0",
repetition = null,
type = 32768,
},
taskOptions = new AdminServiceTaskModel.TaskOptions
{
internalType = 0,
information = "Data Clean up Auto"
},
ignoreErrors = false
};
}
public class DaysOfWeekSource
{
public string name { get; set; }
public int value { get; set; }
public bool isSelectedInternal { get; set; }
}
public class WeeksIntervalOptions
{
public int min { get; set; }
public int max { get; set; }
public int decimals { get; set; }
public string format { get; set; }
}
public class CurrentSchedule
{
public int internalType { get; set; }
public List<int> daysOfWeek { get; set; }
public int weeksInterval { get; set; }
public List<DaysOfWeekSource> daysOfWeekSource { get; set; }
public WeeksIntervalOptions weeksIntervalOptions { get; set; }
}
public class DaysOfWeekSource2
{
public string name { get; set; }
public int value { get; set; }
public bool isSelectedInternal { get; set; }
}
public class WeeksIntervalOptions2
{
public int min { get; set; }
public int max { get; set; }
public int decimals { get; set; }
public string format { get; set; }
}
public class ScheduleByWeek
{
public int internalType { get; set; }
public List<int> daysOfWeek { get; set; }
public int weeksInterval { get; set; }
public List<DaysOfWeekSource2> daysOfWeekSource { get; set; }
public WeeksIntervalOptions2 weeksIntervalOptions { get; set; }
}
public class Schedule
{
public int afterStartMinutesBase { get; set; }
public int beforeStartMinutesBase { get; set; }
public int scheduleType { get; set; }
public string id { get; set; }
public CurrentSchedule currentSchedule { get; set; }
public DateTime startBoundary { get; set; }
public ScheduleByWeek scheduleByWeek { get; set; }
public string maxRunTime { get; set; }
public object repetition { get; set; }
public int type { get; set; }
}
public class TaskOptions
{
public int internalType { get; set; }
public string information { get; set; }
}
public Schedule schedule { get; set; }
public TaskOptions taskOptions { get; set; }
public bool ignoreErrors { get; set; }
}
What I have tried:
I have tried to created a new instance of List<daysofweeksource> and List<daysofweeksource2> but I am unable to get the member properties
public string name { get; set; }
public int value { get; set; }
public bool isSelectedInternal { get; set; }