title: Get raw JSON of object when using OpenJSON
body: <p>This is an awkward thing to word, so if this has been asked before sorry, I couldn't find any answers.</p>
  <p>I'm taking JSON which is a list of objects and storing the fields in a table, however the JSON is from a third party and is prone to adding in new fields, so I'd like to also save the raw JSON of the object. So that if any unhandled fields were added we have the raw JSON, and can update the DB for those fields and run through the stored JSON, so no data is lost.</p>
  <p>I can't however find or figure out how to just get the raw JSON of the current list item.</p>
  <p>Basic OPENJSON I have:</p>
  <pre><code>DECLARE @JSON NVARCHAR(MAX) = '{&quot;data&quot;: [
          {   &quot;id&quot;: 1,
              &quot;name&quot;: &quot;foo&quot;,
              &quot;type&quot;: &quot;bar&quot;,
              &quot;random&quot;: &quot;Potato&quot;},
          {   &quot;id&quot;: 2,
              &quot;name&quot;: &quot;cake&quot;,
              &quot;type&quot;: &quot;special&quot;,
              &quot;random&quot;: &quot;unhandled field&quot;}]}'
  
  SELECT *
  FROM OPENJSON(@JSON, '$.data')
        WITH (
          [id] INT '$.id',
          [type] NVARCHAR(50) '$.type',
          [name] NVARCHAR(50) '$.name'
        ) jsonData
  </code></pre>
  <p>but I can't find anywhere documenting how to also as a field get the entire JSON for the item.</p>
  <p>My ideal tabled output being:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>id</th>
  <th>name</th>
  <th>type</th>
  <th>json</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>foo</td>
  <td>bar</td>
  <td>{ &quot;id&quot;: 1,&quot;name&quot;: &quot;foo&quot;, &quot;type&quot;: &quot;bar&quot;, &quot;random&quot;: &quot;Potato&quot;}</td>
  </tr>
  <tr>
  <td>2</td>
  <td>cake</td>
  <td>special</td>
  <td>{    &quot;id&quot;: 2, &quot;name&quot;: &quot;cake&quot;, &quot;type&quot;: &quot;special&quot;, &quot;random&quot;: &quot;unhandled field&quot;}</td>
  </tr>
  </tbody>
  </table>
  </div>