以数字格式处理Json数据

时间:2016-10-13 04:55:38

标签: json

我如何处理数字中的j子数据?我无法将最后更新的时间存入数据表。

我可以将数据传递给数据表,而不是数字。我应该怎么做才能解决这个问题?这是我的代码,非常感谢。

{
  "response": [
    {
      "location": "44994f77-e633-4d82-847c-1ccbb01e9ec4",
      "type": "Manager",
      "serialNumber": "FOC1537W1ZY",
      "family": "John",
      "lastUpdateTime": 1476263348659,
      "siblings": null,
      "children": "",
      "hiredate": "2016-04-13 02:56:25",
      "medicalStatus": "clear",
      "age": "55",
    }
 ],
"version": "1.0"
}


  public class Response
    {
        public string location { get; set; }
        public string type { get; set; }
        public string serialNumber { get; set; }
        public string family { get; set; }
        public object lastUpdateTime { get; set; }
        public object siblings { get; set; }
        public string children { get; set; }
        public string hireDate{ get; set; }
        public string age{ get; set; }

    }

    public class RootObject
    {
        public List<Response> response { get; set; }
        public string version { get; set; }
    }



        DataTable dtPromotions = new DataTable();
            dtPromotions.Columns.Add("location", typeof(string));
            dtPromotions.Columns.Add("type", typeof(string));
            dtPromotions.Columns.Add("serialNumber", typeof(string));
            dtPromotions.Columns.Add("family", typeof(string));
            dtPromotions.Columns.Add("lastUpdatedTime", typeof(string));
            dtPromotions.Columns.Add("siblings", typeof(string));
            dtPromotions.Columns.Add("children", typeof(string));
            dtPromotions.Columns.Add("hireDate", typeof(string));
            dtPromotions.Columns.Add("age", typeof(string));





            foreach (var off in hostdata2)
            {
                string off1 = Convert.ToString(off);
                string[] RowData = Regex.Split(off1.Replace
                ("{", "").Replace("}", ""), ",");
                DataRow nr = dtPromotions.NewRow();
                foreach (string rowData in RowData)
                {
                    try
                    {
                        int idx = rowData.IndexOf(":");
                        string RowColumns = rowData.Substring
                        (0, idx - 1).Replace("\"", "").Trim();
                        string RowDataString = rowData.Substring
                        (idx + 1).Replace("\"", "");
                        nr[RowColumns] = RowDataString;
                    }
                    catch (Exception ex)
                    {
                        ex.Message.ToString();
                        continue;
                    }
                }
                dtPromotions.Rows.Add(nr);
            }



    RadGrid1.DataSource = dtPromotions;
        RadGrid1.DataBind();

1 个答案:

答案 0 :(得分:0)

您从数据库中获取时间戳值。在日期时间转换它!