This is my controller
[NoCache] public ActionResult SaveAssociate(string data) { JavaScriptSerializer json = new JavaScriptSerializer(); List<string> mystring = json.Deserialize<List<string>>(data); return Content("Hai"); } Expression data value :
[{"AssetName":"8888","AssetNumber":"8888","Classification":null,"ParentAsset":null,"SerialNumber":"8888","ParentCompany":"JPL Holdings","Barcode":null,"RFIDTags":null,"AssetId":"dfe2ae51-f153-4a67-bd3b-0114d8a40751","Notes":null,"Manufacturer":null,"DepartmentId":null,"Department":null,"SupplierId":null,"Supplier":null},{"AssetName":"552014","AssetNumber":"552014","Classification":null,"ParentAsset":"8888","SerialNumber":"552014","ParentCompany":"JPL Holdings","Barcode":null,"RFIDTags":null,"AssetId":"4109ba40-af78-486a-a40e-1d14a2d7b42f","Notes":null,"Manufacturer":null,"DepartmentId":null,"Department":null,"SupplierId":null,"Supplier":null},{"AssetName":"201","AssetNumber":"201","Classification":null,"ParentAsset":null,"SerialNumber":"2011","ParentCompany":"JPL Holdings","Barcode":null,"RFIDTags":null,"AssetId":"3e552280-16df-4c17-a4a5-1f61c4c96835","Notes":null,"Manufacturer":null,"DepartmentId":null,"Department":null,"SupplierId":null,"Supplier":null}] At this line List<string> mystring = json.Deserialize<List<string>>(data); am getting
{"No parameterless constructor defined for type of 'System.String[]'."} even i tried like this
[Serializable] public class GetUser { public GetUserdata[] Data { get; set; } } [Serializable] public class GetUserdata { public string AssetName { get; set; } public string AssetNumber { get; set; } public string Classification { get; set; } public string ParentAsset { get; set; } public string SerialNumber { get; set; } public string ParentCompany { get; set; } public string Barcode { get; set; } public string RFIDTags { get; set; } public string AssetId { get; set; } public string Notes { get; set; } public string Manufacturer { get; set; } public string DepartmentId { get; set; } public string Department { get; set; } public string SupplierId { get; set; } public string Supplier { get; set; } } controller
public ActionResult SaveAssociate(string data) { JavaScriptSerializer json = new JavaScriptSerializer(); GetUser mystring = json.Deserialize<GetUser>(data); return Content("Hai"); } Am getting error Type 'AssetTrackingSystem.Model.GetUser' is not supported for deserialization of an array.
Help me
Listshould be string when it is supposed to hold the return of a deserialization (which I assume would be an object or array or something)Deserializeshouldn't return a string, but your type casting and var names imply that you expect it to. The docs ( msdn.microsoft.com/en-us/library/bb355316(v=vs.110).aspx ) say it returns "The deserialized object."