DataSet ds = DBUtility.Sqlhelper.Query(sb.ToString());
if (ds != null)
{
if (ds.Tables != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
jsonData = Common.ToJson.Dtb2Json(ds.Tables[0]);
//jsonData = Common.ToJson.DataTable2Json(ds.Tables[0]);
}
if (ds != null)
{
if (ds.Tables != null)
{
if (ds.Tables[0].Rows.Count > 0)
{
jsonData = Common.ToJson.Dtb2Json(ds.Tables[0]);
//jsonData = Common.ToJson.DataTable2Json(ds.Tables[0]);
}
}
}
表ds中的值如图所示:
public static string Dtb2Json(DataTable dtb)
{
JavaScriptSerializer jss = new JavaScriptSerializer();
System.Collections.ArrayList dic = new System.Collections.ArrayList();
foreach (DataRow dr in dtb.Rows)
{
System.Collections.Generic.Dictionary<string, object> drow = new System.Collections.Generic.Dictionary<string, o bject>();
foreach (DataColumn dc in dtb.Columns)
{
drow.Add(dc.ColumnName, dr[dc.ColumnName]);
}
dic.Add(drow);
}
//序列化
return jss.Serialize(dic);
}
执行完返回的结果: 0.1 变成了 :0.099999999999 改怎么样解决?
解决方案
40
说明你那个值本来就是0.09999999