I have two JSON files and my requirement is to compare them using PowerShell and form the third JSON with the differences.
For e.g. 1st JSON
{
Name: Mansing
City: Edinburgh
Country: Scotland
}
2nd JSON
{
Name: Mansing
City: Edinburgh
State: Lothian
}
I am expecting the third JSON like below.
{
Name: Mansing
City: Edinburgh
State: Lothian
Country: India
}
I am trying to convert the JSON file to Powershell object using ConvertFrom-Json then want to compare them and form JSON, but I can't find relevant PowerShell commandlet to do so.
$firstFile = Get-Content "C:\Users\shinde_mn\Desktop\first.JSON" |
ConvertFrom-Json
$secondFile = Get-Content "C:\Users\shinde_mn\Desktop\second.JSON" |
ConvertFrom-Json
#$x = $json | ConvertFrom-Json
Write-Host $firstFile
if (Compare-Object $firstFile.PSObject.Properties $secondFile.PSObject.Properties) {
Write-Host "no go"
}