I have a variable with multiple JSON objects.
{
"Objects": [
{
"Name": "Object 2",
"Description": "This is object 2"
},
{
"Name": "Object 3",
"Description": "This is object 3"
},
}
I want to output those into a HTML table:
NAME | DESCRIPTION
Object ... | Object desc ...
I did the following script:
$convData = $jsonObjects | ConvertTo-Html -Fragment
$htmlTable = @"
{
"Title" : "HTML Formatted Table",
"Description" : "This is a table with JSON Objects<br ><br /> $convData"
}
"@
$htmlTable
But the output was:
{ "Title" : "HTML Formatted Table", "Description" : "This is a table with JSON
Objects<br /><br />
<table>
<colgroup>
<col />
<col />
<col />
<col />
<col />
<col />
<col />
</colgroup>
<tr>
<th>Count</th>
<th>IsReadOnly</th>
<th>Keys</th>
<th>Values</th>
<th>IsFixedSize</th>
<th>Sy ncRoot</th>
<th>IsSynchronized</th>
</tr>
<tr>
<td>1</td>
<td>False</td>
<td>
System.Collections.Specialized.OrderedDictionary+OrderedDictionaryKeyValueCollection
</td>
<td>
System.Collections.Specialized.OrderedDictionary+OrderedDictionaryKe
yValueCollection
</td>
<td>False</td>
<td>System.Object</td>
<td>False</td>
</tr>
</table>
" }
Please, can someone point me in the right direction on how to do this? Thank you...
$jsonObjectsis the result of passing the sample json toConvertFrom-Json: Change$jsonObjects | ConvertTo-Html -Fragmentto$jsonObjects.Objects | ConvertTo-Html -Fragment