I have the following code to convert json string to list of objects:
public class rest_all
{
public string restaurants { get; set; }
}
public class rest_all_data
{
public string RestaurantName { get; set; }
public string CategoryName { get; set; }
public string FourSquareID { get; set; }
}
public class rest_collection
{
public IEnumerable<rest_all_data> rest_all_data { get; set; }
}
and here is the main function:
public void AddRestaurantMultiple (rest_all rest_all)
{
JavaScriptSerializer serializer = new JavaScriptSerializer();
rest_collection collection = serializer.Deserialize<rest_collection>(rest_all.restaurants);
}
the problem is that when I make an http request with a json string like this:
{"restaurants" : [{"RestaurantName":"a","CategoryName":"b","FourSquareID":"c"},{"RestaurantName":"d","CategoryName":"e","FourSquareID":"f"}]
it always gives me null at the AddRestaurantMultiple
function...what is it am i doing wrong??