I have created a unique Matrix visual with additional features, but I am currently facing difficulties in extracting the data into JSON format and sending it through an API. Below is the HTML code for the matrix (which resembles a table structure). I would appreciate any suggestions on how to convert this Matrix HTML into JSON format. Could you please provide more detailed explanations? Thank you very much for your assistance!
// Here is the Matrix that needs to be converted into JSON
Northeast Southern
California 5 6
Florida 10 15
// The HTML structure is as follows:
<div class="datagrid">
<table>
<tbody>
<tr>
<th></th>
<th colspan="undefined">Northeast</th>
<th colspan="undefined">Southern</th>
</tr>
<tr>
<th>California</th>
<td>5</td>
<td>6</td>
</tr>
<tr>
<th>Florida</th>
<td>10</td>
<td>15</td>
</tr>
</tbody>
</table>
</div>
// The expected JSON format should look like this:
[
{
"name_column_field": "Northeast",
"value": 5,
"name_row_field": "California"
},
{
"name_column_field": "Northeast",
"value": 10,
"name_row_field": "Florida"
},
{
"name_column_field": "Southern",
"value": 6,
"name_row_field": "California"
},
{
"name_column_field": "Southern",
"value": 15,
"name_row_field": "Florida"
}
]