我需要用这个结构返回 json :
{"asks": [[PRICE, AMOUNT], ...],
"bids": [[PRICE, AMOUNT], ...]}
PRICE
是十进制。AMOUNT
是十进制
例子
{"asks":[[7.449,1],[7.4499,6.711]],
"bids":[[7.40001,5],[7.3325,27.449]]}
我有一个带动作的控制器
public ActionResult GetTrades()
{
///how should I construct the object ?
return Json(data, JsonRequestBehavior.AllowGet);
}
我试图返回这个对象:
public class OrderBook
{
public List<KeyValuePair<decimal, decimal>> asks { get; set; }
public List<KeyValuePair<decimal, decimal>> bids { get; set; }
}
但我得到这样的回应:
{"asks":[{"Key":145.00000,"Value":152.38820689}],
"bids":[{"Key":145.00000,"Value":3.48965517}]}
任何的想法?