title: Powershell JSON object to HTML table and add it to the value of another JSON object
body: <p>I have following JSON object which is dynamically created and can contain special characters in the names e.g. O'Brian in Last Name and special characters in Notes.</p>
  <pre><code>$jsonData = @&quot;
  {
          &quot;ReqId&quot;: 37,
          &quot;First Name&quot;: &quot;John&quot;,
          &quot;Middle Name&quot;: &quot;&quot;,
          &quot;Last Name&quot;: &quot;O'Brian&quot;,
          &quot;Preferred Name&quot;: &quot;John&quot;,
          &quot;Date&quot;: &quot;04/28/2021 05:00:00&quot;,
          &quot;Email&quot;: &quot;test@xyz.com&quot;,
          &quot;Notes&quot;: &quot;This is a note with Special characters&quot;
  }
  &quot;@ | ConvertTo-Json;
  </code></pre>
  <p>I want to use this JSON data and convert it to HTML table format.
  Then pass this HTML data as a value of the key in another JSON object which will then be sent to API.</p>
  <pre><code>$convData = ConvertTo-Html -InputObject ($jsonData);
  $apiJson = @&quot;
      {
          &quot;Title&quot; : &quot;This is Test&quot;,
          &quot;Description&quot; : &quot;This is Test Description.&lt;br &gt;&lt;br /&gt; $convData&quot;
      }
      &quot;@
  </code></pre>
  <p>$apiJson needs to be valid JSON so that API can parse it as a JSON object successfully.</p>
  <p>I tried ConvertTo-HTML method but it is not working and gives empty table. Also I want just <code>&lt;table&gt;...&lt;/table&gt;</code> part and need to remove other tags.</p>
  <pre><code>{
      &quot;Test&quot; : &quot;This is Test&quot;,
      &quot;description&quot; : &quot;This is Test.&lt;br &gt; &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//E
  N&quot;  &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt; &lt;html xmlns=&quot;http://www.w3.org/1999/x
  html&quot;&gt; &lt;head&gt; &lt;title&gt;HTML TABLE&lt;/title&gt; &lt;/head&gt;&lt;body&gt; &lt;table&gt; &lt;colgroup&gt;&lt;col/&gt;&lt;/colgroup&gt; &lt;tr&gt;
  &lt;th&gt;*&lt;/th&gt;&lt;/tr&gt; &lt;tr&gt;&lt;td&gt;539&lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; &lt;/body&gt;&lt;/html&gt;&quot;
  }
  </code></pre>
  <p>Need help. Thank you.</p>