I'm a bit rusty with vb.net and I need your help for encoding this:
{"monday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"tuesday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"wednesday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"thursday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"friday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"saturday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]},"sunday":{"start":"09:00","end":"18:00","breaks":[{"start":"11:20","end":"11:30"},{"start":"14:30","end":"15:00"}]}}
in json format in vb.net, how you can see this string is already encoded in json but I want know how I can create an array or something like for store the days with the break time. Essentially:
"monday":{
"start":"09:00",
"end":"18:00",
"breaks":[
{
"start":"11:20",
"end":"11:30"
},
{
"start":"14:30",
"end":"15:00"
}
]
},
"tuesday":{
"start":"09:00",
"end":"18:00",
"breaks":[
{
"start":"11:20",
"end":"11:30"
},
{
"start":"14:30",
"end":"15:00"
}
]
},
I guess for create this type of content the best idea should be to use a dictionary.
Someone could show a properly and fast way to get this result?
UPDATE:
workWeek.saturday.starttime = User.saturday_start.Value
workWeek.saturday.endtime = User.saturday_end.Value
How you can see I pass to the class variable for saturday
working day the properly start and end date from a DateTimePicker called saturday_start
and saturday_end
.
Now from your hint, I want to know after these data have been entered, how can I encode in json?
UPDATE #2 - Adding breaks
For Each row As DataGridViewRow In User.break_view.Rows
If Not row.IsNewRow Then
Console.WriteLine(row.Cells(0).Value.ToString)
If row.Cells(0).Value.ToString = "Monday" Then
workWeek.monday.breaks.starttime = row.Cells(1).Value.ToString ' <- This is also wrong I guess, it's not this the way for add the break to a specific day?
End If
... other day condition ..
End If
Next