Convert string to objects?

I managed to capture text about holidays like this: Text capture

How can I format/convert it to objects so I can use it like here, where the dates where in a json file?

Output the values to pscustomobject

$test2 = [pscustomobject]$test

This converts it to a object i guess, but it is still one piece of text.
How can i format it to have a name and date collum, with this kind of date format?:

$uri = ''
$html = Invoke-WebRequest -Uri $uri
$table = $html.ParsedHtml.getElementsByTagName('tr') |
Where-Object {$_.classname -eq 'holiday'} |
Select-Object -exp innerHTML

foreach ($t in $table){
    [void]($t -match 'SPAN title="(.*?)"') ; $m1 = $Matches[1]
    [void]($t -match 'tooltip>(.*)') ; $m2 = $Matches[1]
    [void]($t -match 'remarks>(.*) ') ; $m3 = $Matches[1]
        Date = $m1 ; Holiday = $m2
        Remarks = If ($m2 -ne $m3){$m3}}
# Results
Date                       Holiday                    Remarks                  
----                       -------                    -------                  
January 01                 New Year's Day                                      
January 02                 Day after New Years Day                             
March 14                   Summer Day                                          
March 21                   Nevruz                     Spring Festival. Persi

Thanks. Looks like where on to something.

Tested with Alabnia as country, and added DateTime to the variable and got the correct format.

Then tested with Norway as country, and got it like this:
Not working

With Norway and several other countries there is also a class named publicholiday.

Would I have to alter this script for each contry that’s difrent?

Check this tool: json formatter
Hope this help!

Hello Alexander,
Please use the below code and let me know if it works:

# Read data from URI
$uri = ''
$html = Invoke-WebRequest -Uri $uri

# Get the column header and save it into a list - $header_list
$header_table = $html.ParsedHtml.getElementsByTagName('TR')
$data = $header_table[0].cells
$header_list = New-Object System.Collections.ArrayList

foreach($i in $data) {

# Get the holiday data
$data_table = $html.ParsedHtml.getElementsByTagName('TR') | where {$_.classname -eq 'holiday'}
$final_object_list = New-Object System.Collections.ArrayList

foreach($i in $data_table) {
$header_count = 0
    $single_row_entry = $i.cells
    $object = New-Object System.Object
    foreach ($j in $single_row_entry){
        $value = $j.outertext

        if ($j.outerText -eq $null){
            $value = " "
        $object | Add-Member –MemberType NoteProperty –Name $header_list[$header_count++] –Value $value
    # Print each object that we are creating
    write-host ($object | format-list | out-string)
    Write-Host " "

# Convert the object to JSON
$json_Object = $final_object_list | ConvertTo-Json