zoukankan      html  css  js  c++  java
  • dataTable转换成Json格式

     /// <summary> 
            /// dataTable转换成Json格式 
            /// </summary> 
            /// <param name="dt"></param> 
            /// <returns></returns> 
            public string DataTableToJson(DataTable dtChild)
            {
                StringBuilder jsonBuilder = new StringBuilder();
                jsonBuilder.Append("[");
                for (int i = 0; i < dtChild.Rows.Count; i++)
                {
                    jsonBuilder.Append("{");
                    for (int j = 0; j < dtChild.Columns.Count; j++)
                    {
                        jsonBuilder.Append("\"");
                        jsonBuilder.Append(dtChild.Columns[j].ColumnName);
                        jsonBuilder.Append("\":\"");
                        jsonBuilder.Append(dtChild.Rows[i][j].ToString());
                        jsonBuilder.Append("\",");
                    }
                    jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
                    jsonBuilder.Append("},");
                }
                jsonBuilder.Remove(jsonBuilder.Length - 1, 1);
                jsonBuilder.Append("]");
                return jsonBuilder.ToString();
            }
            #endregion       

  • 相关阅读:
    你欠我的幸福,怎么弥补
    爱,请你走开
    一生为你
    爱你到底
    粒子滤波简介(转载)
    关于小波变换和Gabor变换的一些知识!
    基于Opencv的MeanShift跟踪算法实现
    opencv学习网页
    基于OpenCV库的Gabor滤波器的实现
    Mean Shift算法(CamShift)
  • 原文地址:https://www.cnblogs.com/cjmtt/p/2844759.html
Copyright © 2011-2022 走看看