title: C# - Supply ViewModel from JSON string result
body: <p>Good day, </p>
  
  <p>I need a help in extracting JSON string and supply it on my view model.</p>
  
  <p>In my example, I have a ViewModel that has 2 classes.</p>
  
  <p>Classes:</p>
  
  <pre><code>public class Student {
      public int StudentId {get;set;}
      public string Firstname {get;set;}
      public string Lastname {get;set;}
  }
  
  public class Address {
      public int AddressId {get;set;}
      public string Street {get;set;}
  }
  </code></pre>
  
  <p>ViewModel:</p>
  
  <pre><code>public class StudentAddressViewModel{
      public Student Student {get;set;}
      public Address Address {get;set}
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>public async Task&lt;IActionResult&gt; Create(IFormCollection studentInfo){
      // wherein studentInfo is the key
      ...
  }
  </code></pre>
  
  <p>In my controller, I'm sending this JSON string.</p>
  
  <pre><code>{[studentInfo,{"Student":{"firstname":"Johhny","lastname":"Bravo"},"Address":{"street":"New york street..."}])
  </code></pre>
  
  <p>I'm trying this:</p>
  
  <pre><code>var studentInfo = studentInfo["studentInfo"];
  
  var value = JsonConvert.DeserializeObject&lt;Dictionary&lt;string,string&gt;&gt;(studentInfo);
  
  var studentVm = new StudentAddressViewModel{
      new Student{
          Firstname: value["firstname"], Lastname: value["lastname"]
      },
      new Address{
          Address: value["address"]
      }
  }
  </code></pre>
  
  <p>But I'm having a null <code>value</code>.</p>
  
  <p>Any help, please?</p>