title: Json.NET parse array in object
body: <p>I'm having an extremely difficult time parsing multiple arrays out of an array, embedded in several object in JSON.</p>
  <p>Basically the json looks like</p>
  <pre><code>{
   took:8,
   success:true,
   items:[
    keywords:{...},
    mainInfo:{
      name:'...',
      expDate:'...',
      targetCities:[...],
      targetStates:[...]
    },
    additionalInfo:{
      skills:[],
      homeTime:''
    }
  }
  </code></pre>
  <p>My C# looks like:</p>
  <pre><code>public class Job{
    public string name{get;set;}
    public List&lt;string&gt; targetCities{get;set;}
    public List&lt;string&gt; targetStates{get;set;}
    public List&lt;string&gt; skills{get;set;}
    public string homeTime{get;set;}
  }
  public class Jobs{
    private JObject o;
    private List&lt;Job&gt; jobs;
    public Jobs(string json){
      this.o=JObject.Parse(json);
    }
    public List&lt;Job&gt; toList(){
      List&lt;JObject&gt; allJobs=o[&quot;items&quot;].Select(t =&gt; (JObject)t).ToList();
      foreach(JObject i in allJobs){
        Job j=new Job();
        j.name=(string)i[&quot;mainInfo&quot;][&quot;name&quot;];
        j.targetCities=i[&quot;mainInfo&quot;][&quot;targetCities&quot;].Select(t =&gt;(string)t).ToList();
        j.targetStates=i[&quot;mainInfo&quot;][&quot;targetStates&quot;].Select(t =&gt;(string)t).ToList();
        j.expDate=(string)i[&quot;mainInfo&quot;][&quot;expDate&quot;]
        j.skills=i[&quot;additionalInfo&quot;][&quot;skills&quot;].Select(t =&gt;(string)t).ToList();
        j.homeTime=(string)i[&quot;additionalInfo&quot;][&quot;homeTime&quot;];
        this.jobs.Add(j); //ERROR
      }
      return this.jobs;
  }
  </code></pre>
  <p>The error is a <code>Null Reference Exception</code>, with the info <code>Object reference not set to an instance of an object.</code>, however it seems that this error jumps around almost unpredictably as I try and change my code to fix the bug.</p>
  <p>I am by no means a C# or .NET expert. I had dealt with the language in the past, but I personally do not like it. So forgive me for any stupid error I may have made.</p>
  <h2>ADDITION:</h2>
  <p>I'm basically stepping through all the items and trying to create a <code>Job</code> object from each item using the data accordingly.</p>