Friday, June 2, 2017

Finally got Newtonsoft to read an array of objects.

Imports Newtonsoft.Json
Imports Newtonsoft.Json.Linq
Module Module1

   Sub Main()
      Dim sTemp As String
   
      Dim sr As New IO.StreamReader("e:\sre\temp\rest1.txt")
      sTemp = sr.ReadToEnd
      sr.Close()
   
      Dim a As JArray
      Dim a1 As JObject
      a = JsonConvert.DeserializeObject(sTemp)
      For Each a1 In a
         Dim data As List(Of JToken) = a1.Children().ToList
         For Each item As JProperty In data
            'item.CreateReader()
            Debug.WriteLine(item.Name)
            Select Case item.Name
               Case "timeZone"
                  Debug.WriteLine(item.Value.ToString)
            End Select
         Next
      Next
   End Sub