title: JSON object shows as Null. Why?
body: <p>This is the class Database:</p>
  
  <pre><code>namespace vVvBot.Model
  {
      public class Database
      {
          public List&lt;CustomCommand&gt; CustomCommands { get; set; }
          public List&lt;CustomEvent&gt; CustomEvents { get; set; }
      }
  }
  </code></pre>
  
  <p>This is the class for CustomEvent:</p>
  
  <pre><code>namespace vVvBot.Model
  {
      public class CustomEvent
      {
          public string Name { get; set; }
          public bool Enabled { get; set; }
          public List&lt;CustomCommand&gt; Commands { get; set; }
      }
  }
  </code></pre>
  
  <p>This is the class CustomCommand:</p>
  
  <pre><code>namespace vVvBot.Model
  {
      public class CustomCommand
      {
          public string Keyword { get; set; }
          public CommandType Type { get; set; }
          public string Message { get; set; }
          public bool Enabled { get; set; }
      }
  }
  </code></pre>
  
  <p>This is the class where I deserialize and serialize the Database object</p>
  
  <pre><code>namespace vVvBot.Data
  {
      public class FileJsonContext
      {
          public Database ReadToObject(string fileName)
          {
              dynamic jsonData = File.ReadAllText(fileName);
  
              return JsonConvert.DeserializeObject&lt;Database&gt;(jsonData) ?? new Database();
          }
  
          public void ObjectToFile(string fileName, Database database)
          {
              dynamic jsonData = JsonConvert.SerializeObject(database, Formatting.Indented);
  
              File.WriteAllText(fileName, jsonData);
          }
      }
  }
  </code></pre>
  
  <p>In the file with the issue, this is where I instantiate Database:</p>
  
  <pre><code>private Database _database;
  public Database Database =&gt; _database ?? (_database = JsonContext.ReadToObject("Commands.txt"));
  </code></pre>
  
  <p>The line with the issue is:</p>
  
  <pre><code>var messageindex = Database.CustomEvents[index].Commands.FindLastIndex(x =&gt; x.Type == CommandType.Welcome);
  </code></pre>
  
  <p>It tries to complete the line but immediately returns because its comes back with null. There is a List in the custom events that should call the customcommand list so I can access the object. Not sure why it comes back to NULL.</p>
  
  <p>The Json File includes:</p>
  
  <pre><code>{
    "CustomCommands": [
      {
        "Keyword": "Hello",
        "Type": 0,
        "Message": "World",
        "Enabled": true
      },
      {
        "Keyword": "Test",
        "Type": 0,
        "Message": "test",
        "Enabled": true
      },
      {
        "Keyword": "greeting",
        "Type": 3,
        "Message": "this isnt a test ",
        "Enabled": true
      },
      {
        "Keyword": "leaving",
        "Type": 4,
        "Message": "Sorry to see you go ",
        "Enabled": true
      },
      {
        "Keyword": "faq",
        "Type": 1,
        "Message": "This is a FAQ TEST ",
        "Enabled": true
      },
      {
        "Keyword": "Hi",
        "Type": 0,
        "Message": "Hilo ",
        "Enabled": false
      },
      {
        "Keyword": "Hi",
        "Type": 0,
        "Message": "Hilo ",
        "Enabled": false
      }
    ],
    "CustomEvents": [
      {
        "Name": "greeting",
        "Enabled": true
      },
      {
        "Name": "leaving",
        "Enabled": true
      }
    ]
  }
  </code></pre>