I created a generic function that retreives a JSON and parses it:
public IList<Object> RetrieveView(string result)
{
JavaScriptSerializer ser = new JavaScriptSerializer();
IList<Object> values = ser.Deserialize< IList<Object> >(result);
return values;
}
The problem that i have alot of Classes that uses this.
for example when i try to use this:
IList<Receipt> receipts = (IList<Receipt>)RetrieveView(result);
I get InvalidCastException
Unable to cast object of type 'System.Collections.Generic.List[System.Object]' to type 'System.Collections.Generic.IList[Receipt]'.
Anyway to keep my function Generic and be able to cast it to all of my classes/models?