I have this function in ASP.NET to convert a DataTable to JSON string:
Public Function GetJson(ByVal dt As DataTable) As String
Dim serializer As System.Web.Script.Serialization.JavaScriptSerializer = New System.Web.Script.Serialization.JavaScriptSerializer()
Dim rows As New List(Of Dictionary(Of String, Object))
Dim row As Dictionary(Of String, Object)
Try
For Each dr As DataRow In dt.Rows
row = New Dictionary(Of String, Object)
For Each col As DataColumn In dt.Columns
row.Add(col.ColumnName, dr(col))
Next
rows.Add(row)
Next
Return serializer.Serialize(rows)
Catch ex As Exception
logFile("SP GetJson ----" + ex.Message)
Return "-1"
End Try
End Function
but now I have a list of 2 DataTables that I need to convert it to one JSON string that has 2 arrays, in other words i have 2 datatables and i need to convert them in one json string but i need each datatable in json array in the same string
any ideas?