I just can’t find a suitable solution for this problem, although I came across the same topic that was asked earlier.
Here is my Json example that I am posting to the api web controller
{
"AppointmentId ":2079,
"manageaptarray":[
"VanId":6,
"Doctors":[
{"Id":1,"Name":Doc1},
{"Id":2,"Name":Doc2}
]
]}
Here is my C # class
public class ManageDoctorModel
{
public int Id { get; set; }
public int AppointmentId { get; set; }
public DateTime? AppointmentAt { get; set; }
public DateTime ScheduledAt { get; set; }
public int? ModifiedBy { get; set; }
public DateTime? ModifiedDateTime { get; set; }
public Nullable<bool> rCreate { get; set; }
public Nullable<bool> rUpdate { get; set; }
public Nullable<bool> rDelete { get; set; }
public Nullable<bool> rView { get; set; }
public jsonarray[] manageaptarray { get; set; }
}
public class jsonarray
{
public int VanId { get; set; }
public string VanName { get; set; }
public List<Doctorslist> Doctors { get; set; }
}
}
when I do this, I get the error "cannot deserialize the current json array (for example, 1 2 3) to type ...."
I searched around the stack and other forums, most of which were to deserialize the json array. Here is what I did in my C # code
List<jsonarray> jsondata = JsonConvert.DeserializeObject<System.Collections.Generic.List<jsonarray>>(value.manageaptarray.ToString());
Note: value is a parameter where I get this json.
I tried some changes in my class files, for example, to do an idictionary <string,object>, but this gives me the same error.
Since I work with angularjs, I tried the following
json.stringify(jsondata)
angular.tojson(jsondata)
json.parse(jsondata)
. , . , , , - , . , - , , .
2016 < 3
: , , json.