来自数据库的信息并转换为Json以在视图中的bootgrid中显示
我想在bootgrid中显示从数据库获取的数据,但在json中转换数据的方法中有错误。显示错误,如无法从“system.collections.generic.list”转换为货币、无法从int转换为货币以及无法从字符串[]转换为货币来自数据库的信息并转换为Json以在视图中的bootgrid中显示,json,database,asp.net-mvc-4,Json,Database,Asp.net Mvc 4,我想在bootgrid中显示从数据库获取的数据,但在json中转换数据的方法中有错误。显示错误,如无法从“system.collections.generic.list”转换为货币、无法从int转换为货币以及无法从字符串[]转换为货币 enter code here public ActionResult listCurrencyJson() { string strJson = ""; if (Request.IsAjaxRequest())
enter code here public ActionResult listCurrencyJson()
{
string strJson = "";
if (Request.IsAjaxRequest())
{
var keyValues = new Dictionary<string, currency>
{
{ "rows", context.currency.ToList()},
{ "rowCount", context.currency.Count()}
{"current", Request.Params.GetValues("current")}
};
JavaScriptSerializer js = new JavaScriptSerializer();
strJson = js.Serialize(keyValues);
return Json(strJson, JsonRequestBehavior.AllowGet);
}
return Json(strJson, JsonRequestBehavior.AllowGet);
}
这是什么货币?是一个列表吗?我用Dictionary解决了Dictionary的问题,但当我这样做时,有两行JavaScriptSerializer js=newjavascriptserializer;strJson=js.keyvalues;我得到的值类型Datetime返回不同的格式,如/Date1422943200000/