title: Parse JSON to Insert Records into table
body: <p>I have a web server which is connected to MS SQL with tables having foreign keys. My client code sends me the records in one big JSON string. My server receives it and I want to parse it so that I can insert records into appropriate tables. </p>
  
  <p>Here is my db schema:</p>
  
  <pre><code>Table1   
  {      
      INT PID    
      INT CID      
      STRING firstname         
      STRING lastname    
  }
  
  TABLE2  
  {  
      INT CID  
      INT ORDER  
  }
  </code></pre>
  
  <p>TABLE1 has CID as a foreign key.</p>
  
  <p>The sample input JSON would be something like</p>
  
  <pre><code>{
  TABLE1     
  {   
  "firstname":"Tony"  
  
  "lastname":"Stark"  
  }  
  TABLE2  
  {  
  "ORDER":"1234"  
  }  
  }  
  </code></pre>
  
  <p>What's the best approach for this?</p>