My input looks like this:
[
{
"somenums": "1",
"someDate": "1.1.2014",
"viewdata": "1119958",
"visitdata": "152452",
"uniquedata": "125873"
},
{
"somenums": "2",
"someDate": "2.1.2014",
"viewdata": "1863752",
"visitdata": "241453",
"uniquedata": "200762"
}
]
I haven't been able to find a lot on how to handle a file like this containing multiple rows. One scrap of info I did find is that Json will deserialize objects enclosed in square brackets as a List.
After fumbling around to get rid of syntax errors I have ended up with the code below but get a runtime InvalidDirectCast exception on the statement jrrows = DirectCast(JsonConvert.etc.
If ofd.ShowDialog = Windows.Forms.DialogResult.OK Then
My.Settings.LastJsonFileDirectory = Path.GetDirectoryName(ofd.FileName)
My.Settings.Save()
Dim sr As New StreamReader(ofd.FileName)
Dim jrrows As List(Of JsonRow)
jrrows = DirectCast(JsonConvert.DeserializeObject(sr.ReadToEnd), List(Of JsonRow))
End If
End Sub
End Class
<Serializable()> _
Public Class JsonRow
Public somenums As String
Public someDate As String
Public viewdata As String
Public visitdata As String
Public uniquedata As String
Sub New() 'we need a parameter-less constructor to make it serializable
End Sub
End Class