title: Parsing a JSON File with same properties but different "Names"
body: <p>I'm new to JSON and can't wrap my head around the following problem:</p>
  
  <p>I'm getting a JSON file from a third party program. The JSON looks like this:</p>
  
  <pre><code>{
  "Name 1": {
      "Property 1": 154600,
      "Property 2": true,
      "Property 3": 5340,
      "Property 4": 54634
    },
    "Name 2": {
      "Property 1": 5436,
      "Property 2": false,
      "Property 3": 45678769,
      "Property 4": 2342342
    }
  }
  </code></pre>
  
  <p>I need to get them in a Listview with a column for every Property and the Name.</p>
  
  <p>I generated a class with the JSONUtils website:</p>
  
  <pre><code>    Public Class Name1
  
          &lt;JsonProperty("Property 1")&gt;
          Public Property Property1 As Integer
  
          &lt;JsonProperty("Property 2")&gt;
          Public Property Property2 As Boolean
  
          &lt;JsonProperty("Property 3")&gt;
          Public Property Property3 As Integer
  
          &lt;JsonProperty("Property 4")&gt;
          Public Property Property4 As Integer
      End Class
  
      Public Class Name2
  
          &lt;JsonProperty("Property 1")&gt;
          Public Property Property1 As Integer
  
          &lt;JsonProperty("Property 2")&gt;
          Public Property Property2 As Boolean
  
          &lt;JsonProperty("Property 3")&gt;
          Public Property Property3 As Integer
  
          &lt;JsonProperty("Property 4")&gt;
          Public Property Property4 As Integer
      End Class
  
      Public Class NameList
  
          &lt;JsonProperty("Name 1")&gt;
          Public Property Name1 As Name1
  
          &lt;JsonProperty("Name 2")&gt;
          Public Property Name2 As Name2
      End Class
  </code></pre>
  
  <p>But because of the changing Names I would have to dynamically add those classes on runtime.</p>
  
  <p>Next I tried to generate a class which looks like this:</p>
  
  <pre><code>    Public Class NameList
  
          Public Property Name As String
  
          &lt;JsonProperty("Property 1")&gt;
          Public Property Property1 As Integer
  
          &lt;JsonProperty("Property 2")&gt;
          Public Property Property2 As Boolean
  
          &lt;JsonProperty("Property 3")&gt;
          Public Property Property3 As Integer
  
          &lt;JsonProperty("Property 4")&gt;
          Public Property Property4 As Integer
      End Class
  </code></pre>
  
  <p>That would be as intended, but when i run the testprogram, I'm getting an error:</p>
  
  <pre><code>System.NullReferenceException: "Object reference not set to an instance of an object."
  </code></pre>
  
  <p>Below my code:</p>
  
  <pre><code>Dim client As New WebClient()
  Dim stream As Stream = client.OpenRead("C:\\Filename.json")
  Dim reader As New StreamReader(stream)
  Dim jsonData As String = reader.ReadToEnd
  
  reader.Close()
  
  Dim allData As JObject = JObject.Parse(jsonData)
  
  Dim nameDataList As New List(Of NameList)
  
  For Each token As JToken In allData("")
  
        Dim prop As JProperty = token
  
        If Not prop.Name.StartsWith("_") Then
            nameDataList.Add(New NameList With {
                .Name = prop.Name,
                .Property1 = prop.Value("Property 1"),
                .Property2 = prop.Value("Property 2"),
                .Property3 = prop.Value("Property 3"),
                .Property4 = prop.Value("Property 4")})
        End If
  
  Next
  
  </code></pre>
  
  <p>After that comes the code to add the token to my Listview.</p>
  
  <p>The Error occours on this line:</p>
  
  <pre><code>For Each token As JToken In allData("")
  </code></pre>
  
  <p>How can i avoid this error?</p>
  
  <p>Thanks in advance :)</p>