'''<summary>
''' dataTable转换成Json格式
'''</summary>
'''<param name="dt"></param>
'''<returns></returns>
Public Shared Function DataTable2Json(ByVal dt As System.Data.DataTable) As String
Dim jsonBuilder As New StringBuilder()
jsonBuilder.Append("{""Name"":""" & dt.TableName & """,""Rows")
jsonBuilder.Append(""":[")
For i As Integer = 0 To dt.Rows.Count - 1
jsonBuilder.Append("{")
For j As Integer = 0 To dt.Columns.Count - 1
jsonBuilder.Append("""")
jsonBuilder.Append(dt.Columns(j).ColumnName)
jsonBuilder.Append(""":""")
jsonBuilder.Append(dt.Rows(i)(j).ToString().Replace("""", "\"""))
'对于特殊字符,还应该进行特别的处理。
jsonBuilder.Append(""",")
Next
jsonBuilder.Remove(jsonBuilder.Length - 1, 1)
jsonBuilder.Append("},")
Next
jsonBuilder.Remove(jsonBuilder.Length - 1, 1)
jsonBuilder.Append("]")
jsonBuilder.Append("}")
Return jsonBuilder.ToString()
End Function
'''<summary>
''' DataSet转换成Json格式
'''</summary>
'''<param name="ds">DataSet</param>
'''<returns></returns>
Public Shared Function Dataset2Json(ByVal ds As System.Data.DataSet) As String
Dim json As New StringBuilder()
json.Append("{""Tables"":")
json.Append("[")
For Each dt As System.Data.DataTable In ds.Tables
json.Append(DataTable2Json(dt))
json.Append(",")
Next
json.Remove(json.Length - 1, 1)
json.Append("]")
json.Append("}")
Return json.ToString()
End Function
经过查看你给的Demo,发现你采用了迭代取所有的节点一次性加载出来,这样子不能实现按需加载的功能,假若节点数据很多,而且节点的属性也很多的情况下,则加载会更慢。是否能做到异步和按需加载?同时我们想知道该 Studio for ASP.NET Wijmo 控件包所应用的 js 及 css 资源有多大的size?谢谢! |