json is passed from browser using POST method to ASP.NET MVC4 application controller in server. It contains properites from which 3 are arrays of 0.. 20 elements (in code below all of them have only 1 element). How to parse this json in C# ? I tried controller with signature
public JsonResult RegisterSales(Sale mysale)
but mysale properties are not assigned.
passed json:
{ "id":"sale1",
"sale_date":"2013-11-10 19:20:44"
"taxes":[{"id":"km20pr","name":"20%","rate":0.2}],
"products":[{"id":"prod1",
"sale_id":"sale1",
"register_id":"register1",
"quantity":"1.00000"}],
"payments":[{"id":"payment1",
"sale_id":"sale1",
"register_id":"register1",
"amount": 0
}]
}
It should parsed to C# structure something like
public class Sale
{
public string id;
public DateTime sale_date;
public Tax[] taxes;
public Product[] products;
public Payment[] payments;
}
public class Tax
{
public string id, name;
public decimal rate;
}
public class Product
{
public string id, sale_id, register_id;
public decimal quantity;
}
public class Payment
{
public string id, sale_id, register_id;
public decimal amount;
}