/// <summary>
        /// DataTable 转JSON 速度最快
        /// </summary>
        /// <example>
        /// <code>
        /// Data.GetDataTable("Select MemberID,RealName from UC_Member").ToDataTableJson();
        /// </code>
        /// </example>
        /// <param name="dt">DataTable</param>
        /// <returns>JSON字符串</returns>
        public static string ToDataTableJson(this DataTable dt)
        {
            if (dt.IsNull())
            {
                return("[]");
            }
            StringBuilder jsonHtml = new StringBuilder();

            jsonHtml.Append("[");

            JavaScriptSerializerString serializer = new JavaScriptSerializerString();

            foreach (DataRow row in dt.Rows)
            {
                jsonHtml.Append("{");
                foreach (DataColumn col in dt.Columns)
                {
                    jsonHtml.AppendFormat("\"{0}\":{1},", col.ColumnName, serializer.Serialize(row[col]));
                }
                jsonHtml.Remove(jsonHtml.Length - 1, 1);
                jsonHtml.Append("},");
            }
            dt.Dispose(); dt = null;

            if (jsonHtml.Length > 1)
            {
                jsonHtml.Remove(jsonHtml.Length - 1, 1);
            }
            jsonHtml.Append("]");
            return(jsonHtml.ToString());
        }
        /// <summary>
        /// IDataReader 转JSON 速度最快
        /// </summary>
        /// <example>
        /// <code>
        /// Data.GetDbDataReader("Select MemberID,RealName from UC_Member").ToDataReaderJson(true);
        /// </code>
        /// </example>
        /// <param name="dr">IDataReader扩展</param>
        /// <param name="isClose">是否关闭DataReader</param>
        /// <returns>转JSON</returns>
        public static string ToDataReaderJson(this IDataReader dr, bool isClose)
        {
            if (dr.IsNull())
            {
                return("[]");
            }
            StringBuilder jsonHtml = new StringBuilder();

            jsonHtml.Append("[");

            JavaScriptSerializerString serializer = new JavaScriptSerializerString();

            while (dr.Read())
            {
                jsonHtml.Append("{");
                for (int i = 0, len = dr.FieldCount; i < len; i++)
                {
                    jsonHtml.AppendFormat("\"{0}\":{1},", dr.GetName(i), serializer.Serialize(dr[i]));
                }
                jsonHtml.Remove(jsonHtml.Length - 1, 1);
                jsonHtml.Append("},");
            }
            if (isClose)
            {
                dr.Close(); dr.Dispose(); dr = null;
            }

            if (jsonHtml.Length > 1)
            {
                jsonHtml.Remove(jsonHtml.Length - 1, 1);
            }
            jsonHtml.Append("]");
            return(jsonHtml.ToString());
        }
        /// <summary>
        /// DataTable 转JSON 速度最快
        /// </summary>
        /// <param name="dt">DataTable</param>
        /// <param name="fields">字段列表</param>
        /// <param name="alias">别名</param>
        /// <returns>JSON字符串</returns>
        public static string ToJson(this DataTable dt, int[] fields, string[] alias)
        {
            if (dt.IsNull())
            {
                return("[]");
            }
            if (alias.IsNull() || fields.Length != alias.Length)
            {
                Msg.WriteEnd("参数错误!");
            }
            if (fields.IsNull() || fields.Length == 0)
            {
                return(dt.ToDataTableJson());
            }

            JavaScriptSerializerString serializer = new JavaScriptSerializerString();
            StringBuilder jsonHtml = new StringBuilder();

            jsonHtml.Append("[");
            foreach (DataRow row in dt.Rows)
            {
                jsonHtml.Append("{");
                int i = 0;
                foreach (int col in fields)
                {
                    jsonHtml.AppendFormat("\"{0}\":{1},", alias[i], serializer.Serialize(row[col])); i++;
                }
                jsonHtml.Remove(jsonHtml.Length - 1, 1);
                jsonHtml.Append("},");
            }
            dt.Dispose(); dt = null;

            if (jsonHtml.Length > 1)
            {
                jsonHtml.Remove(jsonHtml.Length - 1, 1);
            }
            jsonHtml.Append("]");
            return(jsonHtml.ToString());
        }
        /// <summary>
        /// IDataReader 转JSON 速度最快
        /// </summary>
        /// <param name="dr">IDataReader扩展</param>
        /// <param name="fields">字段</param>
        /// <param name="alias">别名</param>
        /// <returns>转JSON</returns>
        public static string ToJson(this IDataReader dr, string[] fields, string[] alias)
        {
            if (dr.IsNull())
            {
                return("[]");
            }
            if (alias.IsNull() || fields.Length != alias.Length)
            {
                alias = fields;
            }
            if (fields.IsNull() || fields.Length == 0)
            {
                return(dr.ToJson());
            }

            JavaScriptSerializerString serializer = new JavaScriptSerializerString();
            StringBuilder jsonHtml = new StringBuilder();

            jsonHtml.Append("[");

            while (dr.Read())
            {
                jsonHtml.Append("{");
                for (int i = 0, len = fields.Length; i < len; i++)
                {
                    jsonHtml.AppendFormat("\"{0}\":{1},", alias[i], serializer.Serialize(dr[fields[i]]));
                }
                jsonHtml.Remove(jsonHtml.Length - 1, 1);
                jsonHtml.Append("},");
            }
            dr.Close(); dr.Dispose(); dr = null;

            if (jsonHtml.Length > 1)
            {
                jsonHtml.Remove(jsonHtml.Length - 1, 1);
            }
            jsonHtml.Append("]");
            return(jsonHtml.ToString());
        }