I need to generate Json-output like this:
{
"01:30":{
"FREE":true,
"PRICE":3500
},
"03:00":{
"FREE":true,
"PRICE":2500
},
"13:30":{
"FREE":true,
"PRICE":2500
}
}
My problem here is time string - its dynamic from one entry to another. I can not figure out how to construct my c# class (model) that will be serialized into proper json result. My model looks like this now:
public class ScheduleViewModel
{
public ScheduleInnerViewModel TIME { get; set; }
}
public class ScheduleInnerViewModel
{
public bool FREE { get; set; }
public int PRICE { get; set; }
}
Output result is (wrong):
[
{"TIME":{
"FREE":true,
"PRICE":3500
}},
{"TIME":{
"FREE":true,
"PRICE":2500
}},
{"TIME":{
"FREE":true,
"PRICE":2500
}}
]
I use standard way to generate json result from controller:
List<ScheduleViewModel> model = new List<ScheduleViewModel>();
//fill the model...
return this.Json(model, JsonRequestBehavior.AllowGet);
