Prem Rathore

Prem Rathore

  • NA
  • 4
  • 11.2k

json file convert in to dataset using vb.net

Jun 20 2019 1:51 AM
Dear sir
 
how can convert gstr1 json file in to dataset using vb.net with different tables 
 my code is below
Private Sub Button10_Click(sender As Object, e As EventArgs) Handles Button10.Click
'Read Json Data From Text File
Dim Json As String = File.ReadAllText("C:\Users\Genuis\Downloads\BP\GSTR1-Jan2017\jan20173.json")
' Dim Json As String = File.ReadAllText("C:\Users\Genuis\Downloads\BP\GSTR1-Jan2017\jan2017.Json")
Dim jsonParts As String() = Json.Replace("[", "").Replace("]", "").Split("},{")
'Convert JSON Data to DataTable
'DataSet myDataTable = JsonConvert.DeserializeObject<DataTable>(Json);
'Convert JSON Data to DataSet
Dim myDataSet As DataSet = JsonConvert.DeserializeObject(Of DataSet)(Json)
'Check Table Count in DataSet
If (myDataSet.Tables.Count > 0) Then
If (myDataSet.Tables(0).Rows.Count > 0) Then
'Bind Table[0] into grdOrderDetails GridView
DataGridView1.DataSource = myDataSet.Tables(0)
' grdOrderDetails.DataBind()
End If
If (myDataSet.Tables(1).Rows.Count > 0) Then
'Bind Table[1] into grdCompanyDetails GridView
DataGridView1.DataSource = myDataSet.Tables(1)
End If
End If
End Sub
 

Attachment: Jan2017.rar

Answers (1)