title: Inserting a JSON Object into a database
body: <p>I am building a DataSnap server in Delphi XE2, and I'm having trouble figuring out the best way to insert the JSON Object that the client sends me into a Database.</p>
  
  <p>Here's the format of the object I'm receiving:</p>
  
  <pre><code>{"PK":0,"FIELD1":"EXAMPLE","FIELD2":5, "DATE":""}
  </code></pre>
  
  <p>The solution I found was the following code</p>
  
  <pre><code>with qryDBMethods do
    begin
      SQL.Text := 'SELECT * FROM Table';
      Open;
      Append;
      FieldByName('PK')    .AsInteger := StrToInt(newId.ToString)
      FieldByName('FIELD1').AsString  := Object.Get('FIELD1').JsonValue.Value;
      FieldByName('FIELD2').AsInteger := StrToInt(Object.Get('FIELD2').JsonValue.Value); 
      FieldByName('DATE')  .AsDateTime:= Now;    
      Post;
  </code></pre>
  
  <p>After that, I would have my query component made into a JSON Object and returned to my client, but problem is, this is going to be a big application with dense tables and so doing a "SELECT * " every time I want to insert something isn't ideal. What is the best way to do this?</p>